Open Draeggon opened 2 years ago
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).
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
Add websocket for :
And we needed to add this fonctionnality in the service.ts and use it in the application
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.
user_id[]
) informs the client that the "population" of the current room changed.user_id[]
) updates the list of currently writing users.room_id
) make the server put the client into the correct room. (And remove them from their old room)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.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.
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)