Game Servers

Overview

When players in the same room finished the matchmaking process and are ready to play together, they need to connect to the game servers that are assigned for their room to use the SocketWeaver GamePlay API.

When players finished their match, they need to disconnect from the game servers.

You can use the ConnectToRoom(Action) and the DisconnectFromRoom() method to connect/disconnect clients from the game servers.

Example

// Connect to the game servers of the room.
void ConnectToRoom()
{
    NetworkClient.Instance.ConnectToRoom(HandleConnectedToRoom);
}

// Callback method NetworkClient.Instance.ConnectToRoom();
// If connected is true,the client has connected to the game servers successfully.</param>
void HandleConnectedToRoom(bool connected)
{
    if (connected)
    {
        Debug.Log("Connected to room");
        // load the game scene
        SceneManager.LoadScene(1);
    }
    else
    {
        Debug.Log("Failed to connect to room");
    }
}

Last updated