Register Player
Players must register to the lobby server before accessing other lobby APIs.
Methods | |
Called by players to begin an asynchronous operation to register to the Lobby. | |
Called by players to begin an asynchronous operation to register to the Lobby and using the specified string as custom data. | |
Called by players to begin an asynchronous operation to register to the Lobby and using the specified object as custom data. |
Class | |
The response object when the operation finished successfully. | |
The error that occurred when a lobby API operation failed. |
Maximum size of a player custom data is 2KB.
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);
}
});
Last modified 3yr ago