So guys, I'm having a problem with my multiplayer game. My multiplayer game is based on the famous slither.io game, it is almost ready, but I have a bug / problem that I can not solve, maybe you can help me.

Link to full image: https://postimg.org/image/lplv1gyhf/

I have created a system of creation and rooms so that players can create or connect to an existing room, and this is where the problem lives. If I open two windows at the same time of the game before connecting, I can enter the room quietly as a host and as a peer. But if I open a game window on my browser, I enter a room and then try to enter with another user, the two enter as host and stand alone in the room, as if it had two rooms with the same name. And as it is a multiplayer game with random players around the world, I believe not to talk and combine to open the windows at the same time.

(In this picture i used two tabs at same time)

link to full image: https://postimg.org/image/btks1tspf/

So how can I solve this problem, so that even if a player has created a room within 5 minutes he can receive a peer who has just opened the game on another computer?