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.