Lobby and rooms
Join-or-create
There is no separate "create room" call. joinRoom joins the room if it exists, otherwise creates it, and you become its master. Two games calling joinRoom("arena-1") at the same moment end up in the same room.
| Action | Data | Reply event |
|---|---|---|
joinRoom | roomName (required), maxPlayers, isVisible, isOpen, customProperties | roomJoined { room, players } |
leaveRoom | none | roomLeft { roomId, playerId } |
listRooms | limit (default 20, max 50), nextToken | roomList { rooms, nextToken } |
getRoomState | none | roomState { room, players } |
Rules worth knowing:
- Options only apply when the room is created. If the room already exists,
maxPlayers,isVisible,isOpenandcustomPropertiesin your call are ignored. - Room names are normalised. The room id is the name lower-cased with anything other than letters, digits,
_and-replaced by_."Arena 1"and"arena_1"are the same room. The original name is kept for display. - One room at a time. Joining while already in a room returns
ALREADY_IN_ROOM. - Closed or full rooms return
ROOM_FULL. A room is closed whenisOpenis false. - Limits.
maxPlayersis capped at 50 and at the app's ownmaxPlayersPerRoom. Creating a room past the app'smaxRoomsreturnsPLAN_LIMIT_EXCEEDED. - If two players try to create the same new room at the same instant, one may get
INTERNAL_ERROR("please retry"). Retrying joins the room that now exists.
Visibility: the lobby
listRooms returns only rooms that are visible and open. It never returns customProperties (use getRoomState after joining for those). Use isVisible = false for private rooms people join by name or code, like a private match.
Paging: pass the nextToken from the previous reply to get the next page. A missing nextToken means you reached the end.
What a room looks like
{
"roomId": "arena-1", "roomName": "Arena 1", "appId": "...",
"maxPlayers": 8, "currentPlayerCount": 3,
"isVisible": true, "isOpen": true,
"customProperties": { "mode": "deathmatch", "randomSeed": 1893022 },
"hostConnectionId": "abc123=", "createdAt": "...", "lastActivityAt": "..."
}
roomJoined also carries players, each with playerId, playerName, joinedAt, customProperties, and the connection id.
Who hears what
When you join, you get roomJoined and everyone else gets playerJoined { playerId, playerName, connectionId, joinedAt }. When you leave, others get playerLeft { playerId, playerName } (and hostChanged first if you were master).
Room properties (shared, master-controlled)
setRoomProperties { properties: { ... } } is master only. The keys you send are merged into the room's custom properties (existing keys you do not mention are kept) and everyone, including the master, receives roomPropertiesChanged { properties } containing the full merged set.
Use them for state that new joiners need: game mode, map, round number, lobby status, the random seed. They cannot change maxPlayers, isOpen or isVisible after creation.
Player properties (shared, self-controlled)
setPlayerProperties { properties: { ... } } merges into your own properties (team, ready, loadout). Everyone in the room, including you, receives playerPropertiesChanged { playerId, playerName, properties } with the full merged set for that player.
Room lifecycle
first joinRoom ──▶ room created (you are master)
│
others join ──▶ playerJoined to everyone else
│
master leaves ──▶ hostChanged (longest-present player)
│
last player leaves ──▶ room deleted
(nobody ever leaves cleanly) ──▶ room expires after 48 hours
Unity
var state = await client.JoinRoomAsync("arena-1", new RoomOptions {
MaxPlayers = 8,
CustomProperties = new() { { "mode", "deathmatch" } }
});
var rooms = await client.ListRoomsAsync(); // visible, open rooms
await client.SetRoomPropertiesAsync(new() { { "round", 2 } }); // master only
await client.SetPlayerPropertiesAsync(new() { { "team", "red" } });
await client.LeaveRoomAsync();
SetRoomPropertiesAsync / SetPlayerPropertiesAsync do not wait for the server; listen to OnRoomPropertiesChanged / OnPlayerPropertiesChanged for the confirmed values.