public Client(
String apiToken,
String apiPrivateToken,
String baseUrl,
Logger logger
)
Initializes the SDK with API tokens and optional custom base URL. Uses Jackson Databind for JSON serialization.
public static <T> PlayerRegisterResponse registerPlayer(
Client client,
String name,
T playerData
) throws IOException
Registers a new player with optional custom data. Uses generic type for player data with Jackson serialization.
public static <T> PlayerAuthResponse<T> authenticatePlayer(
Client client,
String playerToken
) throws IOException
Authenticates a player using their private token. Returns player information with typed data support.
public static PlayerListResponse getAllPlayers(
Client client
) throws IOException
Retrieves a list of all players (requires private API token).
public static PlayerHeartbeatResponse sendPlayerHeartbeat(
Client client,
String playerToken
) throws IOException
Updates player heartbeat to maintain online status. Call every 30-60 seconds.
public static PlayerLogoutResponse logoutPlayer(
Client client,
String playerToken
) throws IOException
Logs out a player and updates their last logout timestamp.
public static PlayerRenameResponse renamePlayer(
Client client,
String playerToken,
String newName
) throws IOException
Renames a player to a new name. Validates name length (2-50 characters) and requires player authentication.
public static PlayerBanResponse banPlayer(
Client client,
int playerId,
BanTime banDuration,
String banReason
) throws IOException
Bans a player from the game with specified duration (HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, FOREVER) and optional reason. Requires private API token.
public static PlayerUnbanResponse unbanPlayer(
Client client,
int playerId
) throws IOException
Unbans a previously banned player. Requires private API token.
public static boolean isBanned(ApiResponse response)
Checks if an API response indicates the player is banned. Returns true if the error message contains "You are banned".
public static <T> GameDataResponse<T> getGameData(
Client client
) throws IOException
Retrieves global game data with Jackson compatible nested objects.
public static <T> SuccessResponse updateGameData(
Client client,
T data
) throws IOException
Updates global game data (requires private API token). Uses generic type for type safety.
public static <T> PlayerDataResponse<T> getPlayerData(
Client client,
String playerToken
) throws IOException
Retrieves a specific player's data using their authentication token with typed support.
public static <T> SuccessResponse updatePlayerData(
Client client,
String playerToken,
T data
) throws IOException
Updates a specific player's data like level, score, and inventory with generic type support.
public static ServerTimeResponse getServerTime(
Client client
) throws IOException
Retrieves current server time in multiple formats including UTC timestamp.
public static ServerTimeWithOffsetResponse getServerTimeWithOffset(
Client client,
int utcOffset
) throws IOException
Retrieves server time with specified UTC offset adjustment.
public static <T> RoomCreateResponse createRoom(
Client client,
String playerToken,
String roomName,
int maxPlayers,
String password,
boolean hostSwitch,
boolean canLeaveRoom,
T rules,
T playerData
) throws IOException
Creates a new game room for multiplayer sessions with typed rules support, host switching, and player data. Max players: 2-16.
public static RoomListResponse getRooms(
Client client,
String search,
Integer limit
) throws IOException
Retrieves a list of all available game rooms with typed rules support. Supports search and limit parameters (limit: 1-50).
public static <T> RoomJoinResponse joinRoom(
Client client,
String playerToken,
String roomId,
String password,
T playerData
) throws IOException
Joins an existing game room with optional password and player data.
public static RoomLeaveResponse leaveRoom(
Client client,
String playerToken
) throws IOException
Leaves the current game room.
public static RoomPlayersResponse getRoomPlayers(
Client client,
String playerToken
) throws IOException
Retrieves a list of all players in the current room.
public static HeartbeatResponse sendRoomHeartbeat(
Client client,
String playerToken
) throws IOException
Sends heartbeat to maintain connection in game room.
public static <T> CurrentRoomResponse<T> getCurrentRoom(
Client client,
String playerToken
) throws IOException
Gets comprehensive room state including player lists and pending actions with typed support.
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.
public static RoomKickResponse kickPlayer(
Client client,
String playerToken,
int playerId
) throws IOException
Kicks a player from the game room (Host Only). Cannot kick yourself.
public static SuccessResponse updateRoomPassword(
Client client,
String playerToken,
String password
) throws IOException
Updates the room password (Host Only). Use empty string to remove password.
public static ActionSubmitResponse submitAction(
Client client,
String playerToken,
SubmitAction<?> request
) throws IOException
Submits a game action to specific targets (host, all, others, or specific players) with typed request data.
public static ActionPollResponse pollActions(
Client client,
String playerToken
) throws IOException
Polls for completed actions from other players with typed response data.
public static ActionPendingResponse<?> getPendingActions(
Client client,
String playerToken
) throws IOException
Retrieves a list of pending actions that need to be processed with typed request data.
public static ActionCompleteResponse completeAction(
Client client,
String actionId,
String playerToken,
ActionComplete<?> request
) throws IOException
Marks an action as completed with response data using typed ActionComplete parameter.
public static UpdatePlayersResponse updatePlayers(
Client client,
String playerToken,
UpdatePlayers<?> request
) throws IOException
Sends updates to specific players or all players. Uses typed UpdatePlayers parameter.
public static PollUpdatesResponse pollUpdates(
Client client,
String playerToken,
PollUpdates request
) throws IOException
Polls for updates from other players. Returns list of update messages with typed data.
public static TokenResponse getToken(
Client client,
String playerToken
) throws IOException
Retrieves a realtime authentication token for WebSocket connections.
public boolean connect(
String realtimeToken
)
Connects to the realtime WebSocket server using the provided token.
public void send(
ERoomTargetPlayer target,
String command,
Object data,
int[] targetIds
)
Sends a message to the specified players via WebSocket.
public void disconnect()
Disconnects from the WebSocket server and cleans up resources.
public static MatchmakingListResponse getLobbies(
Client client,
String search,
Integer limit
) throws IOException
Retrieves a list of all available matchmaking lobbies with typed rules support.
public static MatchmakingCreateResponse createMatchmakingLobby(
Client client,
String playerToken,
String matchmakingName,
int maxPlayers,
boolean strictFull,
boolean joinByRequests,
boolean hostSwitch,
boolean canLeaveRoom,
boolean realtimeRoom,
String password,
Object playerData,
Object rules
) throws IOException
Creates a matchmaking lobby with typed player data and rules support. Supports approval-based or direct join modes.
public static MatchmakingDirectJoinResponse joinDirectly(
Client client,
String playerToken,
String matchmakingId
) throws IOException
Joins a matchmaking lobby directly (requires lobby to be in direct join mode).
public static MatchmakingJoinRequestResponse requestToJoinMatchmaking(
Client client,
String playerToken,
String matchmakingId,
Object playerData
) throws IOException
Requests to join a matchmaking lobby (requires lobby to be in approval mode).
public static MatchmakingPermissionResponse respondToJoinRequest(
Client client,
String playerToken,
String requestId,
EMatchmakingRequestAction action
) throws IOException
Responds to a join request (APPROVE or REJECT). Host only.
public static MatchmakingCurrentResponse getCurrent(
Client client,
String playerToken
) throws IOException
Gets current matchmaking lobby status with typed rules support.
public static MatchmakingPlayersResponse getPlayers(
Client client,
String playerToken
) throws IOException
Gets list of players in the matchmaking lobby with typed player data.
public static MatchmakingStartResponse startGame(
Client client,
String playerToken
) throws IOException
Starts the game from matchmaking lobby and creates a room. Host only.
public static MatchmakingLeaveResponse leave(
Client client,
String playerToken
) throws IOException
Leaves the current matchmaking lobby.
public static MatchmakingHeartbeatResponse sendHeartbeat(
Client client,
String playerToken
) throws IOException
Sends heartbeat to maintain connection in matchmaking lobby.
public static MatchmakingRemoveResponse removeLobby(
Client client,
String playerToken
) throws IOException
Removes the matchmaking lobby (Host Only).
public static MatchmakingKickResponse kickPlayer(
Client client,
String playerToken,
int playerId
) throws IOException
Kicks a player from the matchmaking lobby (Host Only).
public static SuccessResponse updatePassword(
Client client,
String playerToken,
String password
) throws IOException
Updates the matchmaking lobby password (Host Only).
public static MatchmakingRequestStatusResponse checkJoinRequestStatus(
Client client,
String playerToken,
String requestId
) throws IOException
Checks the status of a specific join request.
public static LeaderboardResponse<?> getLeaderboard(
Client client,
String[] sortBy,
int limit
) throws IOException
Retrieves leaderboard sorted by specified fields with typed player data support.