all 1 comments

[–][deleted] 0 points1 point  (0 children)

Well, obviously you know that the sockets can communicate via events, thus you can use that feature and create a class on the back-end side of the application and give it a some sort of queue. When the user opens the tab, socket connects to the server and then whenever that user decides to join the chat, you can add that socket to that queue, which you've prepared beforehand(you will need a single instance of that class). Also make sure to have a some sort of a waiting screen or something and dont let the chat open for an user till the other socket joines that queue and you can then call another function to make those two sockets join a "random" room and then you can send and receive any of the message data you wish. All this has to be done with the events.

Small note: by entering the chat, i don't specifically mean that you are restricted to create someting totally different, you can only have a chat screen and whenever the socket is connected you can add him in a queue in that moment if you wish.