Create Room

Overview

Creates a new room and automatically joins the room as its room owner.

Methods

Called by players to begin an asynchronous operation to create a room and using the specified wantRT, and PlayerLimit.

Called by players to begin an asynchronous operation to create a room and using the specified string room custom data, wantRT, and PlayerLimit.

Called by players to begin an asynchronous operation to create a room and using the specified serializable object room custom data, wantRT, and PlayerLimit.

Called by players to begin an asynchronous operation to create a room and using the specified string room custom data, wantRT, PlayerLimit, and index data.

Called by players to begin an asynchronous operation to create a room and using the specified serializable object room custom data, wantRT, PlayerLimit, and index data.

Called by players to begin an asynchronous operation to create a room and using the specified string room custom data, wantRT, PlayerLimit, PlayerTimeToLive, isPrivate, and index data.

Called by players to begin an asynchronous operation to create a room and using the specified serializable object room custom data, wantRT, PlayerLimit, PlayerTimeToLive, isPrivate, and index data.

Class

The index data object of a room.

The error that occurred when a lobby API operation failed.

Maximum size of a room custom data is 5KB.

Examples

In this example, we created a room with serializable object as its custom data. The custom room data has two teams and we assigned the local player to team1.

// Serializable classes for room custom data
[Serializable]
public class RoomCustomData {
	public string name;
	public TeamCustomData team1;
	public TeamCustomData team2;
}

[Serializable]
public class TeamCustomData {
	public List < string > players = new List < string > ();
}
// Create a new RoomCustomData object;
RoomCustomData roomData = new RoomCustomData();

// Set its name to "New Room"
roomData.name = "New Room";

// Create two TeamCustomData objects
// Assign them to team1 and team2 of the RoomCustomData object
roomData.team1 = new TeamCustomData();
roomData.team2 = new TeamCustomData();

// Assign local player to team1 by 
// adding local player's PlayerId to the players list of team1
roomData.team1.players.Add(NetworkClient.Lobby.PlayerId);

// create a new room with the RoomCustomData serializable object
NetworkClient.Lobby.CreateRoom(roomData, true, 4, (successful, roomId, error) =>{
	if (successful) {
		Debug.Log("Room created " + roomId);
	}
	else {
		Debug.Log("Failed to create room " + error);
	}
});

Last updated