C++ SDK — Rooms

Room Management

createRoom
template<typename TPlayerData = nlohmann::json, typename TRules = nlohmann::json>
static RoomCreateResponse createRoom(
    Client& client,
    const std::string& playerToken,
    const std::string& roomName,
    int maxPlayers = 4,
    const std::optional<std::string>& password = std::nullopt,
    bool hostSwitch = false,
    bool canLeaveRoom = true,
    const std::optional<TPlayerData>& playerData = std::nullopt,
    const std::optional<TRules>& rules = std::nullopt
)

Creates a new game room for multiplayer sessions with typed rules support, host switching, and player data. Max players: 2-16.

getRooms
template<typename T = nlohmann::json>
static RoomListResponse<T> getRooms(
    Client& client,
    const std::optional<std::string>& search = std::nullopt,
    const std::optional<int>& limit = std::nullopt
)

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

joinRoom
template<typename T = nlohmann::json>
static RoomJoinResponse joinRoom(
    Client& client,
    const std::string& playerToken,
    const std::string& roomId,
    const std::optional<std::string>& password = std::nullopt,
    const std::optional<T>& playerData = std::nullopt
)

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

leaveRoom
static RoomLeaveResponse leaveRoom(
    Client& client,
    const std::string& playerToken
)

Leaves the current game room.

getRoomPlayers
template<typename T = nlohmann::json>
static RoomPlayersResponse<T> getRoomPlayers(
    Client& client,
    const std::string& playerToken
)

Retrieves a list of all players in the current room.

sendRoomHeartbeat
static HeartbeatResponse sendRoomHeartbeat(
    Client& client,
    const std::string& playerToken
)

Sends heartbeat to maintain connection in game room.

getCurrentRoom
template<typename T = nlohmann::json>
static CurrentRoomResponse<T> getCurrentRoom(
    Client& client,
    const std::string& playerToken
)

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

stopRoom
static SuccessResponse stopRoom(
    Client& client,
    const std::string& playerToken
)

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

kickPlayer
static RoomKickResponse kickPlayer(
    Client& client,
    const std::string& playerToken,
    int playerId
)

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

updateRoomPassword
static SuccessResponse updateRoomPassword(
    Client& client,
    const std::string& playerToken,
    const std::optional<std::string>& password = std::nullopt
)

Updates the room password (Host Only). Use nullopt 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.
  • Calls are synchronous functions that take the client by reference — keep them off the frame-critical path in games that cannot stall, and use the typed template overloads to deserialize player data into your own structs.