How do I remake a multiplayer room as the host?

0 favourites
  • 5 posts
From the Asset Store
Source file (commented event sheets), art and all music included and 100% royalty free.
  • I'm having trouble allowing players to rejoin a game without closing out the game window entirely.

    What I'd like to happen: in a two-player game (like pong), if Player A leaves by clicking a back button or closing the game window, the game stops. Player B is informed that Player A disconnected, and then Player B is sent back to the login layout after disconnecting from the current room. Player B can then go back to the game layout through the login layout, becoming the host for a new game. Player C joins, and the two play as normal.

    This works well if Player A is the host and closes the game window: Player B can then basically make a new room as the host and play Player C.

    However, if Player A is the peer and leaves, the host can not create a new room. They get stuck on the "Joined Room" step. However, a Player C can join and create a new room just fine, and they'll be the new host of that room.

    Attached is an example of what's happening with just a slightly-modified pong example file:

    To reproduce, open two preview windows, allow both "players" to connect and begin the game, and then close the peer window. The host will see that the peer has disconnected and then get sent back to the login layout after disconnecting from the signalling server. After trying to start a new game, the host will get stuck.

    Any ideas as to how to solve this? In theory I would want to have a system like for a chess game or something: you connect with an opponent, play until one of you wins, and then you both get kicked back to the login page to play again against different opponents. Any help is appreciated! Thanks!


  • I haven't checked the file yet, but remember there are two disconnect actions - disconnecting from the signaling server does not disconnect you from the room, which is established between the host and peers. Make sure you're using the right one. Also remember all connection and disconnection actions are asynchronous, so only use the proper triggers to continue with further actions (on disconnected ect)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for your response. No matter what I try as the action, "leave room," Room "disconnect," or Signaling "disconnect," I still end up with the same thing. I do include the asynchronous "on Room/Signaling disconnected," but I still cannot create a new room as the old host of the previous room. Here are some pics:

    Host on the left, peer on the right

    The two play a game

    The peer disconnects/closes the game, which prompts host to disconnect OR leave room OR disconnect from room (I've tried all three), and upon completion of "on disconnected" for those, the host gets sent back to the login layout to ready another game

    The host is now stuck on either the "signaling logging in" step or the "signaling joining room" step (in this case, the "signaling logging in" step)

  • Quick followup, I found what I was missing: I need to both leave the room AND disconnect from the signaling server. Then I can jump back in and start a new game! So the current flow that works is:

    On peer disconnected (for whatever reason) -> leave room

    On left room -> disconnect from signaling server

    On disconnect from signaling server -> go to layout "Login"

    At this point I can jump back in.


  • The multiplayer-room-disconnect action should also leave the room on the signalling server. You don't disconnect from the signalling server at that point though, so you should be able to immediately create/join a new room. Don't try to connect to the signalling server again. You're already connected so on signalling joined won't trigger.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)