Unity (C#) SDK — Rooms

Room Management

Methods for creating and managing game rooms

CreateRoomAsync

public Task<RoomCreateResponse> CreateRoomAsync<T>(string playerToken, string roomName, int maxPlayers = 4, string password = null, bool hostSwitch = false, bool canLeaveRoom = true, T rules = null, T playerData = null, CancellationToken ct = default)

Creates a new game room with optional password, host switching, player data and rules. The creating player becomes the host. Max players: 2-16.

GetRoomsAsync

public Task<RoomListResponse<T>> GetRoomsAsync<T>(string search = "", int limit = 20, CancellationToken ct = default)

Retrieves all available game rooms with typed rules support. Useful for server browser. Supports search and limit parameters (limit: 1-50).

JoinRoomAsync

public Task<RoomJoinResponse> JoinRoomAsync(string playerToken, string roomId, string password = null, T playerData = null, CancellationToken ct = default)

Joins an existing room with password and player data. Password required for private rooms.

GetRoomPlayersAsync

public Task<RoomPlayersResponse> GetRoomPlayersAsync(string playerToken, CancellationToken ct = default)

Lists all players in the current room with heartbeat status.

LeaveRoomAsync

public Task<RoomLeaveResponse> LeaveRoomAsync(string playerToken, CancellationToken ct = default)

Leaves the current room and updates player status.

SendRoomHeartbeatAsync

public Task<HeartbeatResponse> SendRoomHeartbeatAsync(string playerToken, CancellationToken ct = default)

Sends heartbeat to maintain room connection. Call every 30-60 seconds while in room.

GetCurrentRoomAsync

public Task<CurrentRoomResponse> GetCurrentRoomAsync(string playerToken, CancellationToken ct = default)

Gets comprehensive room state including player lists and pending actions.

StopRoomAsync

public Task<SuccessResponse> StopRoomAsync(string playerToken, CancellationToken ct = default)

Stops current game room (Host Only). Completely removes room and all associated data.

KickPlayerAsync

public Task<RoomKickResponse> KickPlayerAsync(string playerToken, int playerId, CancellationToken ct = default)

Kicks a player from the game room (Host Only). Cannot kick yourself.

UpdateRoomPasswordAsync

public Task<SuccessResponse> UpdateRoomPasswordAsync(string playerToken, string password, CancellationToken ct = default)

Updates the room password (Host Only). Use empty string to remove password.

Room lifecycle and host controls

A room is one live game session. Create makes the caller the host; list browses public rooms without needing a player token; join enters by id — with a password for protected rooms. Players lists the occupants of the caller's current room, and leave, heartbeat and current manage the membership lifecycle.

The host gets the controls: stop the room, kick a member, set or clear the password. Room custom data holds shared state — map, mode, phase — that members read to stay in sync, and matchmaking lobbies spawn a linked room when the host starts.

  • Send heartbeat on an interval while joined — lapsed memberships get cleaned up server-side.
  • Room titles are validated against your game's room rules at creation, same pipeline as player names.
  • Choose rooms for direct create-and-join flows, matchmaking when players need a browsable lobby first.
  • SDK methods are async Tasks — await them inside your own async methods, or continue on the main thread when the result touches scene objects. The managed HttpClient transport works in both Mono and IL2CPP builds.