React Native Expo How to disconnect from a socket connection after exiting the room (NodeJs) #4938
Unanswered
Rise-admin1
asked this question in
Q&A
Replies: 2 comments
-
Hi! Did you check our React guide? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Check this out https://socket.io/docs/v3/server-api/#socketleaveroom |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Client Side
Server Side
Current Working: When handleSendMessage is executed and "send-single-message-to-server" event emitted to server and "server-message" event is emitted to client side, It logs
1 server-message executed
and after sending one more message it logs2 server-message executed
. When I leave the room and rejoin the same room and execute the handleSendMessage, it logsI can assume here that when I leave the room and rejoin, the existing socket is still present with the new socket even though I join the same room and I think the disconnection should happen automatically. How can I fix this.
NOTE: The initial connection happens as soon as they open the application without having to be present in any rooms. The same goes for disconnection when the user exits the application.
Edit: After reading a bit more, When I leave a room and rejoin the same room, the socket does not disconnect, so the socket is still running when I exit a room and rejoin.
Beta Was this translation helpful? Give feedback.
All reactions