FSnapshotSync
- Module
- GameNet
- Header
#include "GameNet/SnapshotSync.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
std::function<void(const std::string& state, uint64_t version)> | OnState | Fired when a snapshot is accepted (in order). The payload is the server state verbatim — this class never interprets it. |
std::function<void(uint64_t localId, const std::string& reason)> | OnRollback | Fired when the server rejects an intent: roll the optimistic render back to the last accepted snapshot. |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | ApplySnapshot | Returns false (and drops) when the snapshot is stale or duplicate: versions are totally ordered and the server pushes whole states, so anything <= the last accepted version carries no information. |
void | OnReject | The reject names the oldest in-flight intent (this protocol answers intents in order). |
uint64_t | QueueIntent | Queue an intent for sending. |
std::vector<FPendingIntent> | TakeSendable | Everything ready to go on the wire. |
void | ClearInflightThrough | A snapshot acknowledges every intent the server has folded in: with whole-state pushes there is no per-intent ack, so acceptance = the next accepted snapshot. |
void | OnDisconnected | |
void | OnConnected | |
bool | ConsumeResyncRequest | True once after a (re)connect: the caller sends a resync envelope and the gateway answers with full current state. |
uint64_t | GetVersion | |
bool | HasState | |
bool | IsConnected | |
size_t | OutboxSize | |
size_t | InflightSize |
Function details
ApplySnapshot
bool ApplySnapshot(uint64_t version, const std::string& state)Returns false (and drops) when the snapshot is stale or duplicate: versions are totally ordered and the server pushes whole states, so anything <= the last accepted version carries no information.
OnReject
void OnReject(const std::string& reason)The reject names the oldest in-flight intent (this protocol answers intents in order). Everything queued after it stays queued — the caller decides whether to also drop dependents.
QueueIntent
uint64_t QueueIntent(std::string payload)Queue an intent for sending. Returns the local correlation id.
TakeSendable
std::vector<FPendingIntent> TakeSendable()Everything ready to go on the wire. Empty while disconnected — the outbox holds, nothing is dropped. Sent intents move to the in-flight list until the matching snapshot (acceptance) or reject arrives.
ClearInflightThrough
void ClearInflightThrough(uint64_t version)A snapshot acknowledges every intent the server has folded in: with whole-state pushes there is no per-intent ack, so acceptance = the next accepted snapshot. Call after ApplySnapshot returns true.
OnDisconnected
void OnDisconnected()OnConnected
void OnConnected()ConsumeResyncRequest
bool ConsumeResyncRequest()True once after a (re)connect: the caller sends a resync envelope and the gateway answers with full current state.
GetVersion
uint64_t GetVersion() constHasState
bool HasState() constIsConnected
bool IsConnected() constOutboxSize
size_t OutboxSize() constInflightSize
size_t InflightSize() const