template<typename T = nlohmann::json>
static PlayerRegisterResponse registerPlayer(
Client& client,
const std::string& name,
const std::optional<T>& playerData = std::nullopt
)
Registers a new player with optional custom data. Uses template type for player data with nlohmann::json serialization.
template<typename T = nlohmann::json>
static PlayerRegisterResponse registerPlayerWithSteam(
Client& client,
const std::string& steamTicket,
const std::optional<std::string>& steamIdentity = std::nullopt,
const std::optional<std::string>& name = std::nullopt,
const std::optional<T>& playerData = std::nullopt,
const std::string& playerToken = "",
bool restore = false
)
Registers or logs in a player via a hex-encoded Steam auth ticket from ISteamUser::GetAuthTicketForWebApi (single-use — request a fresh ticket each login). Requires Steam enabled for the project in the API cabinet; the account persists via SteamID.
Mint the ticket with michitai::multiplayer::steam::SteamTicket (Steam/SteamTicket.h) — a thin wrapper over the real Steamworks SDK: steam_api64.lib at link time, steam_api64.dll + steam_appid.txt beside the exe. See the MICHITAI_STEAM demo in examples/Game.cpp.
template<typename T = nlohmann::json>
static PlayerRegisterResponse registerPlayerWithGoogle(
Client& client,
const std::string& googleAuthCode,
const std::optional<std::string>& googleIntegrityToken = std::nullopt,
const std::optional<std::string>& name = std::nullopt,
const std::optional<T>& playerData = std::nullopt,
const std::string& playerToken = "",
bool restore = false
)
Registers or logs in via a Google Play Games server auth code. Pass restore=true only after the player explicitly confirms a deletion-restore prompt; the fresh provider credential can recover the account even after a reinstall.
template<typename T = nlohmann::json>
static PlayerAuthResponse<T> authenticatePlayer(
Client& client,
const std::string& playerToken
)
Authenticates a player using their private token. Returns player information with typed data support.
static PlayerListResponse getAllPlayers(Client& client)
Retrieves a list of all players (requires private API token).
static PlayerHeartbeatResponse sendPlayerHeartbeat(
Client& client,
const std::string& playerToken
)
Updates player heartbeat to maintain online status.
static PlayerLogoutResponse logoutPlayer(
Client& client,
const std::string& playerToken
)
Logs out a player and updates their last logout timestamp.
static PlayerRenameResponse renamePlayer(
Client& client,
const std::string& playerToken,
const std::string& newName
)
Renames a player to a new name. Validates name length (2-50 characters) and requires player authentication.
static PlayerDeleteResponse deleteAccount(
Client& client,
const std::string& playerToken
)
Schedules player-initiated account deletion. The account freezes immediately and is purged after the 30-day grace window unless restored. Keep the player credential during the window; the response includes deletionPending and purgeAfter.
static PlayerRestoreResponse restoreAccount(
Client& client,
const std::string& playerToken
)
Cancels a pending deletion. This must be an explicit player action, never an automatic login or background retry. Provider-linked accounts can also restore after reinstall by signing in with the provider and restore=true after confirmation.
static PlayerBanResponse banPlayer(
Client& client,
int playerId,
EBanTime banDuration,
const std::optional<std::string>& banReason = std::nullopt
)
Bans a player from the game with specified duration (Hour, Day, Week, Month, Quarter, Year, Forever) and optional reason. Requires private API token.
static PlayerUnbanResponse unbanPlayer(
Client& client,
int playerId
)
Unbans a previously banned player. Requires private API token.
static bool isBanned(const ApiResponse& response)
Checks if an API response indicates the player is banned. Returns true if the error message contains "You are banned".
Register creates the player and returns the token your game stores and presents as X-Game-Player-Token. Login re-opens the session on a later run; heartbeat keeps the player marked online while they play; logout ends the session cleanly. Rotate issues a fresh credential and invalidates the old one — call it any time a token may have leaked.
Registration and rename validate the display name server-side against your game's name rules — allowed scripts, case policy and symbols, edited in the cabinet — plus the profanity screen. A rejected name comes back as a fielded error you can show the player instead of guessing why it failed.