GitHub Documentation Patreon donate button

GameServer CallBack



  • Hi all!
    The server side have some call back when client create a client.

    //when client side run this code
    new Colyseus.Client(url);
    
    // zhen server side
    const gameServer = new Server();
    gameServer.onConnection(client); //like this
    
    

    Is there any way I can go from room to room without disconnection? I think such frequent ports will waste computing resources.

    sorry about my english.


  • administrator

    Hi @BlueBang, there is no server connection going on when you instantiate Colyseus.Client on the client-side.

    An HTTP request is sent to the server for requesting to join or create rooms, and an WebSocket connection is created whenever you actually join them. So all your logic must be implemented inside the game rooms.

    Is there any way I can go from room to room without disconnection?

    You need to actually drop the previous WebSocket connection, and open a new one.

    Hope this helps, cheers!



  • @endel i know, thanks and cheers!😂


 

© 2020 Endel Dreyer