GitHub | Documentation | Become a Patron

Creating a room from another room?



  • I have a flow that when a client enters the game, I use getAllAvailableRooms to get all game lobbies a client can join, or allow him to create a new one (See the PR I sent to colyseus).

    After they join a game lobby, they basically join a GameLobby room, which waits until all clients are ready and the owner presses Start and the game should then start.

    My idea is that I should be able to create a room from inside the onMessage function,
    which would in turn give me the newly created roomId, which I can broadcast to my players with a start_game action.

    But unfortunately, a room cannot access the matchmaker...

    Given that - how would you go and make something like that?

    Btw, this is the repo for code example and references.



  • Found sort of a solution - use RegisteredHandler's create event to subscribe to the room's event.
    The changes can be found here.

    I wanna make an important note here:

    Creating an async main method in index.ts and awaiting gameServer.register was crucial.