I would like to create a live notification center by using Web Socket in Python. I have a feature that send / emit a message to specific user.
I have read about socket id and room. I think there are a couple way to do direct user interaction using both feature from Socket IO.
First:
It is said in the docs that every client / socket connected to the socket server, they were giving an unique socket#id and joined a room identified by id. I have an idea that I do not need create a room again for a user, and just by using this default room.
By using these, I want to create a mapping of socket#id with userid (logged user id), and store it into redis. Like, if I want to send a message to a user id, I just need to search for it's socket#id.
The question for this first way is, is the socket#id will be the same if a client disconnect and reconnect soon the connection can be established ?
Second:
I have read many sources about using room for direct message. For connected client or socket, I just need to create a new room with id of the user id that sent from client (after user login).
The advantages of this way is, if the user is using same user id for several device, I can group them in a room. So, if I want to notify to all device, I just need to send the message for room of id user.
The question of this way, is the user will be moved from default room from first way or they will be on 2 room (1 default, 1 specified room by user id) ?
Thank You