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

spinner

Data Flow

spinner

Key Concepts

Concept
Description

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

  1. Create / Join — A NetworkSession subclass is instantiated by the platform-specific NetworkService.

  2. Synchronize — Non-owner clients receive a SynchronizationMessage with the current player list. The owner is immediately synchronized.

  3. Player JoinsOnConnectionApproval validates the connection, OnClientConnected creates the NetworkPlayer, and PlayerJoined fires.

  4. Player LeavesOnClientDisconnected detects the departure, OnPlayerLeft removes the player, and PlayerLeft fires.

  5. Leave / KickLeave() exits the session; KickPlayer() removes a specific player (both abstract, implemented per-platform).

  6. ShutdownShutdown() clears all players and unsubscribes from Netcode callbacks.

Classes

Class
Description

Abstract base class managing session state, player tracking, and synchronization

Read-only struct carrying session metadata

Last updated