class

FMatchConnection

Module
GameNet
Header
#include "GameNet/MatchConnection.h"
Namespace
Mowo

Properties

TypeNameDescription
std::function<void(const std::string& stateJson, uint64_t version)>OnStateFull 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)>OnRejectedThe 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)>OnFinishedTerminal result payload; the connection is done after this.
std::function<void()>OnLostTransport loss (not a graceful finish) — show "reconnecting…".

Constructors

SignatureNameDescription
FMatchConnection()FMatchConnection
~FMatchConnection()~FMatchConnection
FMatchConnection(const FMatchConnection&) = deleteFMatchConnection

Public functions

ReturnsNameDescription
FMatchConnection&operator=
boolConnectBlocking upgrade against <gatewayUrl>?token=<token>.
boolReconnectReconnect after Lost: same URL/token, intents queued while offline flush after the resync in the order the user acted.
voidTickPump once per frame: polls the socket, dispatches envelopes, flushes sendable intents, keeps the heartbeat alive.
uint64_tSendMoveQueue a move intent; moveJson is the envelope data object.
voidSendReactionFire-and-forget reaction (emoji) — not an intent, never queued/rolled back, silently dropped while offline.
voidClose
EMatchConnectionStateGetState
uint64_tGetStateVersion
floatGetSecondsSinceHeardSeconds since the last pong (or connect).
voidSetHeartbeatIntervalHeartbeat cadence; the backend expects ~15 s.

Function details

FMatchConnection

C++
FMatchConnection()

~FMatchConnection

C++
~FMatchConnection()

FMatchConnection

C++
FMatchConnection(const FMatchConnection&) = delete

operator=

C++
FMatchConnection& operator=(const FMatchConnection&) = delete

Connect

C++
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

C++
bool Reconnect()

Reconnect after Lost: same URL/token, intents queued while offline flush after the resync in the order the user acted.

Tick

C++
void Tick(float dt)

Pump once per frame: polls the socket, dispatches envelopes, flushes sendable intents, keeps the heartbeat alive.

SendMove

C++
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

C++
void SendReaction(const std::string& reactionJson)

Fire-and-forget reaction (emoji) — not an intent, never queued/rolled back, silently dropped while offline.

Close

C++
void Close()

GetState

C++
EMatchConnectionState GetState() const

GetStateVersion

C++
uint64_t GetStateVersion() const

GetSecondsSinceHeard

C++
float GetSecondsSinceHeard() const

Seconds 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

C++
void SetHeartbeatInterval(float seconds)

Heartbeat cadence; the backend expects ~15 s.

Generated from GameNet/MatchConnection.h via gamenet.json · Oct 26, 2026Version 1.0.0