Java SDK — Rooms

Room Management

Rooms.createRoom
public static RoomCreateResponse createRoom(
    Client client,
    String playerToken,
    String roomName,
    int maxPlayers,
    String password,
    boolean hostSwitch,
    boolean canLeaveRoom,
    boolean realtime,
    Object playerData,
    Object rules
) throws IOException

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

Rooms.getRooms
public static <T> RoomListResponse<T> getRooms(
    Client client,
    String search,
    Integer limit,
    Class<T> rulesType
) throws IOException

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

Rooms.joinRoom
public static RoomJoinResponse joinRoom(
    Client client,
    String playerToken,
    String roomId,
    String password,
    Object playerData
) throws IOException

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

Rooms.leaveRoom
public static RoomLeaveResponse leaveRoom(
    Client client,
    String playerToken
) throws IOException

Leaves the current game room.

Rooms.getRoomPlayers
public static <T> RoomPlayersResponse<T> getRoomPlayers(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

Retrieves a list of all players in the current room.

Rooms.sendRoomHeartbeat
public static HeartbeatResponse sendRoomHeartbeat(
    Client client,
    String playerToken
) throws IOException

Sends heartbeat to maintain connection in game room.

Rooms.getCurrentRoom
public static <T> CurrentRoomResponse<T> getCurrentRoom(
    Client client,
    String playerToken,
    Class<T> rulesType
) throws IOException

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

Rooms.stopRoom
public static SuccessResponse stopRoom(
    Client client,
    String playerToken
) throws IOException

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

Rooms.kickPlayer
public static RoomKickResponse kickPlayer(
    Client client,
    String playerToken,
    int playerId
) throws IOException

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

Rooms.updateRoomPassword
public static SuccessResponse updateRoomPassword(
    Client client,
    String playerToken,
    String password
) throws IOException

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.
  • Calls return CompletableFuture — compose with thenApply/thenAccept, or join() on a worker thread when blocking is acceptable; never join on a UI or render thread.