Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Game Room Chats #2

Open
QuinnBast opened this issue Apr 11, 2020 · 7 comments
Open

Game Room Chats #2

QuinnBast opened this issue Apr 11, 2020 · 7 comments
Labels
api enhancement New feature or request

Comments

@QuinnBast
Copy link
Contributor

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

  • Global Chat

and may contain several:

  • Group Chats (2 to n participants)

Chat messages should include at a minimum

  • player_id
  • timestamp
  • message (Set a maximum length!)

Furthermore these states will influence how the client displays chats:

  • Blocked - Gives the ability to block a player for
  1. Only the current game
  2. For all games

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:

  • When a player sends a message, only ask for necessary details. This would, for example, include just the session_id and the message. Please do not add unnecessary dependencies like the player_id itself. Current Subterfuge has proven vulnerabilities which allows to send messages as other players, this can be easily avoided. If you need the player_id, player_name etc. fetch it with the session token.
  • Allow the retrieval of chats iff the player has access to it and is authenticated.
@QuinnBast
Copy link
Contributor Author

@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
Copy link
Contributor Author

@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

  • a specific chat
  • all game chats

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
Copy link
Contributor Author

@billyb2 commented:

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

@QuinnBast
Copy link
Contributor Author

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
Copy link
Contributor Author

@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 c907bc9.

@QuinnBast
Copy link
Contributor Author

@billyb2 comment:

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

@QuinnBast QuinnBast added api enhancement New feature or request labels Apr 11, 2020
QuinnBast pushed a commit that referenced this issue May 12, 2020
@griendt
Copy link
Contributor

griendt commented May 17, 2020

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants