FMatchConnection
- Module
- GameNet
- Header
#include "GameNet/MatchConnection.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
std::function<void(const std::string& stateJson, uint64_t version)> | OnState | Full private-view snapshot, verbatim server JSON, strictly increasing version. Fired only for accepted (in-order) snapshots. |
std::function<void(uint64_t localId, const std::string& reason)> | OnRejected | The server refused an intent: roll optimistic UI back to the last OnState payload. localId is the value SendMove returned. |
std::function<void(const std::string& resultJson)> | OnFinished | Terminal result payload; the connection is done after this. |
std::function<void()> | OnLost | Transport loss (not a graceful finish) — show "reconnecting…". |
Constructors
| Signature | Name | Description |
|---|---|---|
FMatchConnection() | FMatchConnection | |
~FMatchConnection() | ~FMatchConnection | |
FMatchConnection(const FMatchConnection&) = delete | FMatchConnection |
Public functions
| Returns | Name | Description |
|---|---|---|
FMatchConnection& | operator= | |
bool | Connect | Blocking upgrade against <gatewayUrl>?token=<token>. |
bool | Reconnect | Reconnect after Lost: same URL/token, intents queued while offline flush after the resync in the order the user acted. |
void | Tick | Pump once per frame: polls the socket, dispatches envelopes, flushes sendable intents, keeps the heartbeat alive. |
uint64_t | SendMove | Queue a move intent; moveJson is the envelope data object. |
void | SendReaction | Fire-and-forget reaction (emoji) — not an intent, never queued/rolled back, silently dropped while offline. |
void | Close | |
EMatchConnectionState | GetState | |
uint64_t | GetStateVersion | |
float | GetSecondsSinceHeard | Seconds since the last pong (or connect). |
void | SetHeartbeatInterval | Heartbeat cadence; the backend expects ~15 s. |
Function details
FMatchConnection
FMatchConnection()~FMatchConnection
~FMatchConnection()FMatchConnection
FMatchConnection(const FMatchConnection&) = deleteoperator=
FMatchConnection& operator=(const FMatchConnection&) = deleteConnect
bool Connect(const std::string& gatewayUrl, const std::string& token)Blocking upgrade against <gatewayUrl>?token=<token>. On success the pending resync goes out immediately, which makes the gateway push full current state — connect and reconnect are deliberately the same path.
Reconnect
bool Reconnect()Reconnect after Lost: same URL/token, intents queued while offline flush after the resync in the order the user acted.
Tick
void Tick(float dt)Pump once per frame: polls the socket, dispatches envelopes, flushes sendable intents, keeps the heartbeat alive.
SendMove
uint64_t SendMove(const std::string& moveJson)Queue a move intent; moveJson is the envelope data object. Returns the local correlation id OnRejected reports back.
SendReaction
void SendReaction(const std::string& reactionJson)Fire-and-forget reaction (emoji) — not an intent, never queued/rolled back, silently dropped while offline.
Close
void Close()GetState
EMatchConnectionState GetState() constGetStateVersion
uint64_t GetStateVersion() constGetSecondsSinceHeard
float GetSecondsSinceHeard() constSeconds since the last pong (or connect). The UI surfaces stalls well before the transport notices — radio silence on mobile looks exactly like a healthy idle socket.
SetHeartbeatInterval
void SetHeartbeatInterval(float seconds)Heartbeat cadence; the backend expects ~15 s.