Sein Net Subsystem
Class · USeinNetSubsystem : UGameInstanceSubsystem
#include "SeinNetSubsystem.h"
The network session: relays, match start, the turn exchange, state transfer for a returning or diverged player, desync checks and replays.
Every process simulates, a dedicated server too. Only commands cross the network.
Start. The server prepares a match (settings and a seed), then builds it once the match world’s actors have begun play (as clients do) and sends both to every player. Each builds tick zero and reports its checksum; when every Human slot has reported the server’s, all start ticking.
Turns. See FSeinLockstep. Commands from the dispatcher’s Route go into this process’s next batch; the server stamps each client batch with its relay’s slot, assembles the turn and sends the same bytes to everyone.
Pause. A pause runs inside the simulation (a turn’s command or a simulation node), so every player pauses at the same tick. A paused world takes no turns, so a resume goes to the server, which sends it to every player with that tick; each runs the resumes for its pause one at a time, in the server’s order, and drops the rest once it has resumed.
Returning players and desyncs. The server captures its state at a turn boundary and sends it in compressed chunks, then the turns after it. The player loads it and catches up. Every Determinism Check Interval turns each client reports its state checksum; a mismatch sends that player the server’s state, or aborts the match, by the Desync Policy.
End. When the world ends the match it stops on that tick, and so does every player’s. The session stops taking commands; each client reports its final checksum and the server compares them with its own, closes the replay and broadcasts On Match Result Verified. The session stays connected.
Replays. The server records every match it plays (see FSeinReplayWriter). A standalone world plays one back and seeks by checkpoint.
C++ members (46)
void ReleaseModuleOwnedStateForModuleUnload();Drop every binding, timer and session before this module’s code unloads.ASeinNetRelay* SpawnRelay(APlayerController* Controller, FSeinPlayerID Slot);Server: give a player controller its relay, seated in Slot (Neutral: its lobby slot, if any). Calling again updates the slot. A player returning to a running match gets the match state. Null when networking is off or the slot belongs to another player.ASeinNetRelay* FindRelay(const APlayerController* Controller) const;ASeinNetRelay* GetLocalRelay() const;The relay of this machine’s player, if it has one.const TArray<TWeakObjectPtr<ASeinNetRelay>>& GetRelays() const;FSeinPlayerID GetLocalPlayerID() const;This machine’s player’s slot; Neutral without a seated relay.void RegisterRelay(ASeinNetRelay& Relay);void UnregisterRelay(ASeinNetRelay& Relay);bool PrepareMatch(const FSeinMatchSettings& Settings);Server: keep the settings and draw a seed for the next match world. A start that travels calls this before ServerTravel; the destination world begins it once its actors have begun play.void CancelPreparedMatch();bool HasPreparedMatch() const;bool BeginPreparedMatch(UWorld& World);Server: build the prepared match in World and send it to every player. The game framework calls this once the match world’s actors have begun play.bool StartMatch(UWorld& World, const FSeinMatchSettings& Settings);Server: prepare a match and begin it in World now, or once its actors have begun play.void AbortMatch(const FString& Reason);Stop the match on this process because it cannot go on; the server stops it for every player.ESeinNetMatchPhase GetPhase() const;int64 GetSessionSeed() const;TArray<FSeinPlayerID> GetPlayersHoldingTurn() const;On the host, while its world waits for a turn: the players whose input for that turn has not arrived, in slot order. Empty otherwise, and always on a client, which does not see other players’ input.bool IsCatchingUp() const;True while this process loads the host’s state or runs turns it fell behind on (a reconnect, a desync repair, a replay seek).bool MayTakeSeat(FSeinPlayerID Slot, bool bOriginalPlayer) const;Server: whether a connecting player may take Slot under its vacant seat policy. bOriginalPlayer is true for the player who last held the seat. A seat whose player hasn’t dropped this match (a lobby, or a seat waiting for its player after travel) takes only its own player.bool RegisterConnectionAdmissionAuthorizer(FName OwnerName, FSeinConnectionAdmissionAuthorizer Authorizer);Install the server’s one external admission authority (an online-services provider). It answers synchronously with the exact slot a connection plays.void UnregisterConnectionAdmissionAuthorizer(FName OwnerName);Remove the authority, only if OwnerName registered it.bool HasConnectionAdmissionAuthorizer() const;bool AuthorizeIncomingConnection(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& OutErrorMessage);PreLogin: ask the authority and keep its answer briefly. False with an error to refuse.bool ConsumeAuthorizedConnection(APlayerController* Controller, const FString& Options, const FUniqueNetIdRepl& UniqueId, FSeinPlayerID& OutSlot, FString& OutErrorMessage);InitNewPlayer: claim the PreLogin answer for the new controller.bool GetAuthorizedConnectionSlot(const APlayerController* Controller, FSeinPlayerID& OutSlot) const;The slot the authority gave a connected controller.void ReleaseAuthorizedConnection(APlayerController* Controller);Forget a controller’s admission (logout, failed login).bool TransferAuthorizedConnection(APlayerController* OldController, APlayerController* NewController, FSeinPlayerID ExpectedSlot);Move an admission to the controller that replaces Old in a seamless travel.bool IsRecordingReplay() const;FString FinishReplayRecording();Publish the current recording; recording stops. Returns its path, or the path of the recording that finished last (a match that ended finishes its own); empty when there is none.bool PlayReplay(UWorld& World, const FString& Path, int32 StartTurn, FString& OutError);Standalone: play a replay file in World from StartTurn.bool SeekReplay(int32 Turn, FString& OutError);Jump the playing replay to Turn from its nearest checkpoint.void StopReplay();Stop playback; the world keeps the state it reached.bool IsPlayingReplay() const;void DescribeStatus(FOutputDevice& Ar) const;bool SimulateDesync(FString& OutError);Perturb this process’s simulation so its next checksum differs (development builds).void ServerReceiveBatch(ASeinNetRelay& Relay, int32 Turn, TConstArrayView<uint8> Part, bool bEnd);void ClientReceiveTurn(ASeinNetRelay& Relay, int32 Turn, TConstArrayView<uint8> Part, bool bEnd);void ServerReceiveChecksum(ASeinNetRelay& Relay, int32 Turn, const FGuid& Checksum);void ServerReceiveFinalChecksum(ASeinNetRelay& Relay, int32 Tick, const FGuid& Checksum);void ClientBeginMatch(ASeinNetRelay& Relay, TConstArrayView<uint8> SettingsBytes, int64 InSeed);void ServerReceiveReady(ASeinNetRelay& Relay, const FSeinStateHeader& Header, const FGuid& Checksum);void ClientStartMatch(ASeinNetRelay& Relay);void ServerReceivePauseControl(ASeinNetRelay& Relay, int32 Tick, TConstArrayView<uint8> Bytes);void ClientReceivePauseControl(ASeinNetRelay& Relay, int32 Tick, TConstArrayView<uint8> Bytes);void ClientBeginState(ASeinNetRelay& Relay, const FSeinStateHeader& Header, int32 Turn, int32 FirstAuthoredTurn, int32 RawSize, int32 CompressedSize);void ClientStateChunk(ASeinNetRelay& Relay, TConstArrayView<uint8> Bytes);