Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

252 [Back] Add flask socketio #269

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Conversation

Draeggon
Copy link
Contributor

i have implemented socketio on the method to get room, @yannis-mlgrn or @viandoxdev could you test if it work on the js side (normally by creating a socket and sending the message "get" you should get the room)

@viandoxdev
Copy link
Contributor

viandoxdev commented Feb 15, 2022

I'll test.
Nvm I can't get docker-compose to work. Also, the only thing we really need to do with sockets (for now) is updates, so the simplest way would be to just broadcast (from the server) an update_msg message with no data to every client, to inform them that a new message has been sent. A much less naive way would be to only update clients that are in the correct room (see socketio rooms maybe).

@viandoxdev viandoxdev marked this pull request as draft February 15, 2022 16:49
@yannis-mlgrn
Copy link
Member

We should just implented websocket for messages updating in the current room ( or maybe every room where the user is added)
But also for update these messages more easily and avoid to DDOS the server because every second all users connected send a HTTP request. This improvement will we allow to add also the "is writing" state

@yannis-mlgrn
Copy link
Member

Add websocket for :

  • updating message
  • is writing state

And we needed to add this fonctionnality in the service.ts and use it in the application

@viandoxdev
Copy link
Contributor

viandoxdev commented Feb 15, 2022

So, summary of what needs to be done with websockets:

The server should handle rooms like so: When a user "goes" into a room (channel), it should send a join event, the server then places the user in the right socketio room. Then when a user sends a message, the server should react by sending a message event to everyone in the room (except for the sending user, with skip_sid).

The server should also send events informing that a user has joined/left (The user clicked in/off or logged off) the current room.

The server should also now keep track of which user is writing, probably not in the Database, but maybe in a big Map<RoomId, UserId[]> at runtime, as that data isn't really important anyways. The server should also now provide two events for that: start_writing and stop_writing, as well as writing_state, that it would send to users of a room along a list of currently writing userId whenever that state changes.

Events

From server to client(s)

  • people(user_id[]) informs the client that the "population" of the current room changed.
  • message(?) informs the clients of a new message.
  • writing_state(user_id[]) updates the list of currently writing users.

From client to server

  • join(room_id) make the server put the client into the correct room. (And remove them from their old room)
  • start_writing() informs the server that the client has started writing.
  • stop_writing() informs the server that the client has stopped writing.

Questions

  • Should the server send the actual message with the message event, or should it send nothing and let the users query it themselves ? Or just send the ID ? Performance wise it would be better to send the message with it.
  • people is a really shitty name.

test

Also see middlewares for auth, even if we won't run any actual check on the backend, we need to be able to associate a websocket connection and a scratchy user.

@yannis-mlgrn yannis-mlgrn changed the title 252 [Back] Add flask socketio to back 252 [Back] Add flask socketio Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants