Messenger

The Messenger subsystem provides a typed, callback-driven messaging layer on top of Unity Netcode's CustomMessagingManager. It enables game systems to send and receive strongly-typed network messages without manually managing serialization, routing, or server relay — while supporting targeted delivery to specific clients.

Architecture

spinner

Message Flow

spinner

Key Concepts

Concept
Description

Handler ID

A string key that groups related messages. Each handler ID maps to one NetworkMessageHandler instance.

Message Header

The AssemblyQualifiedName of the payload type, used to dispatch to the correct callback within a handler.

Server Relay

Clients always send to the server. If the server is not the intended target, it relays the message to the specified target clients.

Payload Types

Messages support primitive types (string, int, byte), Unity vectors (Vector2, Vector3, Vector2Int, Vector3Int), and any INetworkSerializable type.

Unnamed Messages

The system uses Netcode's SendUnnamedMessage API — messages are identified by handler ID in the payload, not by named message registration.

Quick Start

Subscribing to Messages

Sending Messages

Using Custom Serializable Payloads

Classes

Class
Description

Central messaging hub — subscribes handlers, sends messages, receives and routes incoming messages.

Abstract handler base and generic subclass — manages callbacks and deserializes incoming messages per handler ID.

Serializable struct wrapping a typed payload for network transport via INetworkSerializable.

See Also

Last updated