.NET (C#) SDK — Rooms

Room Management

CreateRoomAsync
public Task<RoomCreateResponse> CreateRoomAsync<T>(string gamePlayerToken,
    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 for multiplayer sessions with typed rules support, host switching, and player data. Max players: 2-16.

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

Retrieves a list of all available game rooms with typed rules support. Supports search and limit parameters (limit: 1-50).

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

Joins an existing game room with optional password and player data.

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

Leaves the current game room.

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

Retrieves a list of all players in the current room.

SendHeartbeatAsync
public Task<HeartbeatResponse> SendHeartbeatAsync(
    string gamePlayerToken,
    CancellationToken ct = default)

Sends heartbeat to maintain connection in game room.

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

Gets comprehensive room state including player lists and pending actions with typed support.

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

Stops the current game room (Host Only). Completely removes the 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 = null,
    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.
  • Methods are Task-based async — await them and pass a CancellationToken tied to your game's lifetime so in-flight requests cancel cleanly on shutdown.