Subterfuge-Revived / Remake-Backend

Server side validation and API
Creative Commons Zero v1.0 Universal
10 stars 1 forks source link

Game Room Chats #2

Open QuinnBast opened 4 years ago

QuinnBast commented 4 years ago

This section involves the implementation of room related chats. Game rooms must contain a:

and may contain several:

Chat messages should include at a minimum

Furthermore these states will influence how the client displays chats:

Obviously this would require the ability to unblock someone from either 1. or 2.

The player will send a request to fetch all recent messages after timestamp X from chat Y.

Keep in mind:

QuinnBast commented 4 years ago

@billyb2 Commented:

So could chats just be written onto a text file on the server? It'd be pretty easy to implement and wouldn't have to clog the MySQL database.

So I'm thinking there are two ways this could happen:

  1. Every game has a text file where all the chat messages are stored and in different "sections". As in, a section for public chat, a section for group chats, etc.

Pros: Relatively easy to implement There would be minimal .txt files on the server

Cons: Will be (slightly) more difficult to program If the user somehow exploited the algorithm for reading the chat they could read all chat messages

  1. Every separate group chat, public chat, etc. are stored in different text files. Like if the room id was 256, the text file for a conversation between Bob and Alice would be bob-alice-256.txt

Pros: Very easy to implement User exploits would have to be able to view every text file

Cons: A ton of text files to manage

QuinnBast commented 4 years ago

@XATEV commented:

Clogging the databases wouldn't be an issue, you can create a separate database which stores all chats. A player request would always look like: Give me all messages from either

that I am part of from game room Y. Then you would have one single table in the sandbox database which simply has the entries player_id, chat_id, room_id. We can count chat_id from 0 for each room whereas 0 is the global chat. To get the participants of a chat room you can simply query for the room_id, if you want the chats a player is in (room specific) you query for player_id + room_id.

I am not sure how the file based approach would work and if it would be better performance wise in the end. Also like you said, making sure access is restricted and working correctly would be more difficult.

(MySQL has been in development for nearly 3 decades and it can easily query from a table with millions of entries in less than a second.)

QuinnBast commented 4 years ago

@billyb2 commented:

1 to 1 direct messages are finished with 700002a1, however, you cannot retrieve messages (yet).

QuinnBast commented 4 years ago

Nice work! One thing to think about as well is once we have pulling from the database, we will want users to be able to get live updates from chat messages when they are online in the game. We will need to setup a socket server for users to send and recieve communications from about live chat and game events. This could probably be a new issue once we get there though.

QuinnBast commented 4 years ago

@billyb2 replied:

Nice work! One thing to think about as well is once we have pulling from the database, we will want users to be able to get live updates from chat messages when they are online in the game. We will need to setup a socket server for users to send and recieve communications from about live chat and game events. This could probably be a new issue once we get there though.

Added the ability to receive messages past a certain time frame with c907bc9e.

QuinnBast commented 4 years ago

@billyb2 comment:

Added the ability to block/unblock other players with 98f2f160731e025cec6422be16ff2b6d40671398

griendt commented 4 years ago

Most of this is implemented in the Laravel codebase, however, we cannot yet close this issue as there is one thing missing, namely the Global Chat. Upon room creation a chat with all players should be created (and marked as being a special global chat in some way).