Methods for creating and managing game rooms
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.
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).
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.
public Task<RoomPlayersResponse> GetRoomPlayersAsync(string playerToken, CancellationToken ct = default)
Lists all players in the current room with heartbeat status.
public Task<RoomLeaveResponse> LeaveRoomAsync(string playerToken, CancellationToken ct = default)
Leaves the current room and updates player status.
public Task<HeartbeatResponse> SendRoomHeartbeatAsync(string playerToken, CancellationToken ct = default)
Sends heartbeat to maintain room connection. Call every 30-60 seconds while in room.
public Task<CurrentRoomResponse> GetCurrentRoomAsync(string playerToken, CancellationToken ct = default)
Gets comprehensive room state including player lists and pending actions.
public Task<SuccessResponse> StopRoomAsync(string playerToken, CancellationToken ct = default)
Stops current game room (Host Only). Completely removes room and all associated data.
public Task<RoomKickResponse> KickPlayerAsync(string playerToken, int playerId, CancellationToken ct = default)
Kicks a player from the game room (Host Only). Cannot kick yourself.
public Task<SuccessResponse> UpdateRoomPasswordAsync(string playerToken, string password, CancellationToken ct = default)
Updates the room password (Host Only). Use empty string to remove password.
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.