Session
The Session subsystem manages multiplayer session state — tracking connected players, handling join/leave events, connection approval, and player synchronization. It provides an abstract session model that platform-specific network services implement.
Architecture
Data Flow
Key Concepts
NetworkSession
Abstract base managing session state, player tracking, connection approval, and synchronization messaging. Platform services subclass this.
NetworkSessionInfo
Lightweight read-only struct carrying session metadata (ID, name, max connections) without runtime state.
Connection Approval
The session owner validates incoming connections, rejecting duplicate users and queuing approved connections as PendingConnection records.
Synchronization
When a new client connects, the owner sends the full player list via SynchronizationMessage. Join/leave events are broadcast to all clients.
Session Lifecycle
Create / Join — A
NetworkSessionsubclass is instantiated by the platform-specificNetworkService.Synchronize — Non-owner clients receive a
SynchronizationMessagewith the current player list. The owner is immediately synchronized.Player Joins —
OnConnectionApprovalvalidates the connection,OnClientConnectedcreates theNetworkPlayer, andPlayerJoinedfires.Player Leaves —
OnClientDisconnecteddetects the departure,OnPlayerLeftremoves the player, andPlayerLeftfires.Leave / Kick —
Leave()exits the session;KickPlayer()removes a specific player (both abstract, implemented per-platform).Shutdown —
Shutdown()clears all players and unsubscribes from Netcode callbacks.
Classes
Abstract base class managing session state, player tracking, and synchronization
Read-only struct carrying session metadata
Last updated