Skip to content

Risiverse/risichat-back

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

risichat-back

Risichat backend

Made with Java, Maven, bson, dotenv-java, Java-WebSocket, json, mongodb-driver-sync, slf4j-api, slf4j-log4j12.

Use with Docker

To build the app, run the command

docker build -t risichat-back:1.0.0 .

To run the app, run the command

docker run -p hostPort:localPort -t risichat-back:1.0.0

localPort being the WS server port you chose in the .env file, and hostPort your machine port you want to redirect to.
You may also want to bind Mongodb's port if it runs on the same machine than the container.

Build and run it yourself

You'll need Maven and openjdk 18.

To build the app into a JAR with all dependencies, run the command

mvn clean compile assembly:single

If everything is ok, it should generate an executable .jar file into ./target folder. You can place this file wherever you want.
To run the app, you'll have to first create (or move if already created) the .env file in the target folder, or the same folder you placed the .jar file.
Then, simply run the command

java -jar ./target/risichat-back-jar-with-dependencies.jar

(or replace ./target/risichat-back-jar-with-dependencies.jar with whatever name you gave it and/or where it is located)

Environment variables

  • ./env
    • WS_PORT
    • MONGO_HOST
    • MONGO_DB
    • MONGO_COLLECTION

MONGO_HOST is the MongoDB connection URI.

MongoDB hostname should look something like this mongodb://host.docker.internal:27017 if it runs on the same machine as the container. (host.docker.internal may only work on Windows)

DTOs

All JSON requests should be stringified.

Client to server

New message (to server)

{
    "type": "newMessage",
    "data": {
        "userSSOID": 424242,
        "username": "Didier Deschamps",
        "content": "Hello World!"
    }
}

Server to client

New message (to clients)

{
    "type": "newMessage",
    "data": {
        "timestamp": 1659301486937,
        "username": "Didier Deschamps",
        "content": "Hello World!"
    }
}

User status update

{
    "type": "newConnection",
    "data": {
        "message": "A new user has logged in."
    }
}
{
    "type": "newDisconnection",
    "data": {
        "message": "A user has logged out."
    }
}

Other

{
  "type": "error",
  "message": "JSON Format not valid.",
  "status": 400,
  "data": {
    "userSSOID": "pouet",
    "username": 4242,
    "pouet": "Hello World!"
  }
}

About

Risiverse real time messaging system - backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published