Correct way to do client notification event with socket.io

Viewed 19

I'm working on a chat app in react native which uses socket.io

Chat rooms only have two persons.

On my node server app, when first user joins chat socket.on('joinRoom') trigger an emit io.to("room123").emit("notifyTo"+userTwoId), response) to notify the second user.

On my React native app, I have this event: socket.on("notifyTo"+currentUserId) to notify to current user that user one has joined the chat.

My question is, is this approach correct? regarding the use of the user id to be able to broadcast (from the server) and capture the event (from the client)

0 Answers
Related