Chat System
Server listens for JsonMessage: { "route": "/chat/<chatId>/join" }
- Responds with:
{ type: "Chat", chat: "join", chatId: "<chatId>", users: [{ "playerId": "<uuid>", "name": "RandomCat79" }, { "playerId": "<uuid>", "name": "Zomis" }] } - Send to all current users (including new user) in chat:
{ type="Chat", chat="join", chatId="<chatId>", user: { "playerId": "<uuid>", "name": "RandomCat79" } }
Server listens for JsonMessage: { "route": "/chat/<chatId>/leave" }"
- Responds with:
{ type: "Chat", chat: "leave", chatId: "<chatId>" }(as confirmation) - Sends to all current users in chat:
{ type: "Chat", chat: "left", chatId: "<chatId>", user: { "playerId": "<uuid>", "name": "RandomCat79" } }
Server listens for JsonMessage: { "route": "/chat/<chatId>/message", "message": "<text>" }
- Sends to all users in chat (including the one who sent the message):
{ type: "Chat", chat: "message", chatId:"<chatId>", from: "<playerId>", message: "<text>" }
chatId can be any string.
Backend implementation details: chatId could be something like "game/UR" for a lobby-chat for the game, "server" for a site-wide chat, "game/UR/6" for a game-id-specific chat. Private chats would also be possible in the future using UUIDs.
If implemented on the site, possibly use https://commonmark.org/
Backend can either store chats in-memory, or they can be saved to DynamoDB using something like this:
PK: chat:<chatId>
SK: unix time stamp? or just incremental id?
User: <playerId>
Message:
Start off with just an in-memory storage