Games icon indicating copy to clipboard operation
Games copied to clipboard

Chat System

Open Zomis opened this issue 8 years ago • 2 comments

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.

Zomis avatar Apr 03 '18 21:04 Zomis

If implemented on the site, possibly use https://commonmark.org/

Zomis avatar Jun 15 '20 14:06 Zomis

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

Zomis avatar Apr 10 '21 19:04 Zomis