Messages

Network-serializable message structs used by NetworkSession to synchronize player state across clients. All messages implement INetworkSerializable from Unity Netcode and manually serialize NetworkPlayer data (user ID, user name, client ID) via FastBufferWriter/FastBufferReader.

Architecture

spinner

Message Flow

spinner

When a new client connects:

  1. The host sends a SynchronizationMessage to the new client with the full current player list.

  2. The host broadcasts a PlayerJoinedMessage to all existing clients.

When a client disconnects:

  1. The host broadcasts a PlayerLeftMessage to all remaining clients.

Serialization Format

All messages manually serialize NetworkPlayer fields in the same order:

Field
Type
Description

UserID

string

The user's service identity

UserName

string

The user's display name

ClientID

ulong

The Netcode client connection ID

On deserialization, a new NetworkPlayer is reconstructed from a NetworkUser and the NetworkClient looked up from NetworkManager.API.ConnectedClients.

Classes

Class
Description

Broadcast when a player joins the session

Broadcast when a player leaves the session

Sent to new clients with the full player list

See Also

  • Service — parent subsystem overview

  • NetworkPlayer — the player record serialized by these messages

  • NetworkUser — user identity reconstructed during deserialization

Last updated