Register Player

Overview

Players must register to the lobby server before accessing other lobby APIs.

Methods

Register(Action<bool, SWRegisterReply, SWLobbyError>)

Called by players to begin an asynchronous operation to register to the Lobby.

Register(string, Action<bool, SWRegisterReply, SWLobbyError>)

Called by players to begin an asynchronous operation to register to the Lobby and using the specified string as custom data.

Register(object, Action<bool, SWRegisterReply, SWLobbyError>)

Called by players to begin an asynchronous operation to register to the Lobby and using the specified object as custom data.

Class

SWRegisterReply

The response object when the operation finished successfully.

SWLobbyError

The error that occurred when a lobby API operation failed.

Maximum size of a player custom data is 2KB.

Example

In this example, we are registering the local player with a string "John" as custom data.

string playerName = "John";
NetworkClient.Lobby.Register(playerName, (successful, reply, error) =>{
if (successful) {
Debug.Log("Lobby registered " + reply);
} else {
Debug.Log("Lobby failed to register " + reply);
}
});

In this example, we are registering the local player with a serializable object as custom data.

[Serializable]
public class PlayerData{
public string name;
public string externalId;
}
PlayerData playerData = new PlayerData();
playerData.name = "John";
playerData.externalId = "1234567890";
NetworkClient.Lobby.Register(playerData, (successful, reply, error) =>{
if (successful) {
Debug.Log("Lobby registered " + reply);
} else {
Debug.Log("Lobby failed to register " + reply);
}
});