Client Callbacks

Connection Callbacks

Every callback on this page is a public Broadcaster member of RealtimeClient, except for the custom-event subscriptions listed under Event Subscriptions. Subscribe with client.OnXxx.Subscribe(handler), which returns a Subscription; see Callbacks and Subscriptions for the lifetime rules and RAII helpers.

Callback Fires When Manual Page
OnDisconnected(DisconnectCause cause) The connection ends, requested or not; cause carries the reason. Errors and Disconnects
OnError(ErrorCode code, StringViewType message) An asynchronous error occurs outside a pending operation. Errors and Disconnects
OnCustomAuthStep(const std::unordered_map<StringType, StringType>& data) A custom authentication provider requests another authentication step. Authentication

Room and Player Callbacks

Callback Fires When Manual Page
OnRoomJoined() The local client enters a room, by creating or joining it. Rooms and Players
OnRoomLeft() The local client leaves the current room. Rooms and Players
OnPlayerJoined(const PlayerView& player) A remote player joins the current room. Rooms and Players
OnPlayerLeft(int playerNumber, bool isInactive) A player leaves the current room; isInactive is true when the player may still rejoin. Rooms and Players
OnMasterClientChanged(int newId, int oldId) Mastership moves from player oldId to player newId. Rooms and Players

Property Callbacks

Callback Fires When Manual Page
OnRoomPropertiesChanged(const RealtimeMap& changes) The room's custom properties change; the map contains only the changed keys. Custom Properties
OnPlayerPropertiesChanged(int playerNumber, const RealtimeMap& changes) A player's custom properties change. Custom Properties
OnPropertiesChangeFailed() The server rejects a property update, for example a failed compare-and-swap. Custom Properties

Event Subscriptions

Custom events are not a Broadcaster member. They are registered on RealtimeClient itself, with an event-code filter baked into the subscription; every overload returns the same Subscription type as Subscribe() does. The payload form is deduced from the callback: std::span<const uint8_t> delivers raw bytes, const RealtimeValue& delivers the decoded payload.

Subscription Delivers Manual Page
SubscribeEvent(callback) Every event code, 0 through 255. Custom Events
SubscribeEvent(uint8_t eventCode, callback) Only eventCode. Custom Events
SubscribeEvent(uint8_t firstEventCode, uint8_t lastEventCode, callback) The inclusive code range. Custom Events
SubscribeEvent<Payload>(...) The same three overloads with the payload form named explicitly, std::span<const uint8_t> or const RealtimeValue& (plain RealtimeValue is accepted as shorthand). Custom Events
SubscribeEvent<T>(uint8_t eventCode, callback) eventCode only, decoded into a trivially-copyable T; the callback takes (int senderId, const T& value). Custom Events

The callback signature of the untyped overloads is (uint8_t eventCode, int senderId, PayloadType payload). A byte-span payload points into a decode buffer owned by the subscription and is only valid during the call.

Direct Messaging Callbacks

Callback Fires When Manual Page
OnDirectMessage(int senderId, std::span<const uint8_t> data, bool isRelay) A direct message arrives; isRelay is true when it traveled through the server instead of peer-to-peer. Direct Messaging
OnDirectConnectionEstablished(int remotePlayerId) A peer-to-peer connection to a remote player is established. Direct Messaging
OnDirectConnectionFailed(int remotePlayerId) A peer-to-peer connection attempt to a remote player fails. Direct Messaging

Lobby Callbacks

Callback Fires When Manual Page
OnRoomListUpdated(const std::vector<RoomListing>& rooms) The room list of the joined lobby changes. Lobbies and Matchmaking
OnLobbyStats(const std::vector<LobbyStats>& stats) Lobby statistics arrive, requested via GetLobbyStats() or pushed when AutoLobbyStats is enabled. Lobbies and Matchmaking

Advanced Callbacks

Callback Fires When Manual Page
OnWarning(int warningCode) The SDK reports a non-fatal warning. Errors and Disconnects
OnAppStatsUpdated() The server pushes fresh application statistics; read them via GetStats(). Statistics
OnCacheSliceChanged(int cacheSliceIndex) The room's event cache slice index changes. Event Caching
OnCustomOperationResponse(uint8_t opCode, int errorCode, StringViewType errorString, const RealtimeMap& data) A custom server operation sent with SendCustomOperation() responds. Configuration
Back to top