educative.io

How server handle messages from different users chatting with same user?

The server can maintain a hash table, where “key” would be the UserID and “value” would be the connection object. So whenever the server receives a message for a user, it looks up that user in the hash table to find the connection object and sends the message on the open request.

-As per above text, if server deliver any message meant for a user ID to a same connection object, how we handle 2 simultaneous chat sessions with 2 different people.Can you please explain.

1 Like

This would be handled on the client end. The message would contain meta-data for the message including the sender. So on the client end it would get routed to the right chat window.

Do you know how the Message storing DB schema will look like … I believe once the server receives request for example UserA send message to UserB then server has to first store message details in UserB DB based on sharedId. But server has to also keep int UserA I guess because to keep the track of chat history … correct me if I am wrong… do you know hot the db schema look like . ?