Class CustomMessagingManager
The manager class to manage custom messages, note that this is different from the NetworkManager custom messages. These are named and are much easier to use.
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.Netcode.Runtime.dll
Syntax
public class CustomMessagingManager
Methods
RegisterNamedMessageHandler(string, HandleNamedMessageDelegate)
Registers a named message handler delegate.
Declaration
public void RegisterNamedMessageHandler(string name, CustomMessagingManager.HandleNamedMessageDelegate callback)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the message. |
CustomMessagingManager.HandleNamedMessageDelegate | callback | The callback to run when a named message is received. |
SendNamedMessage(string, IReadOnlyList<ulong>, FastBufferWriter, NetworkDelivery)
Sends the named message
Declaration
public void SendNamedMessage(string messageName, IReadOnlyList<ulong> clientIds, FastBufferWriter messageStream, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced)
Parameters
Type | Name | Description |
---|---|---|
string | messageName | The message name to send |
IReadOnlyList<ulong> | clientIds | The clients to send to |
FastBufferWriter | messageStream | The message stream containing the data |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with |
SendNamedMessage(string, ulong, FastBufferWriter, NetworkDelivery)
Sends a named message
Declaration
public void SendNamedMessage(string messageName, ulong clientId, FastBufferWriter messageStream, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced)
Parameters
Type | Name | Description |
---|---|---|
string | messageName | The message name to send |
ulong | clientId | The client to send the message to |
FastBufferWriter | messageStream | The message stream containing the data |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with |
SendNamedMessageToAll(string, FastBufferWriter, NetworkDelivery)
Sends a named message to all clients
Declaration
public void SendNamedMessageToAll(string messageName, FastBufferWriter messageStream, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced)
Parameters
Type | Name | Description |
---|---|---|
string | messageName | The message name to send |
FastBufferWriter | messageStream | The message stream containing the data |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with |
SendUnnamedMessage(IReadOnlyList<ulong>, FastBufferWriter, NetworkDelivery)
Sends unnamed message to a list of clients
Declaration
public void SendUnnamedMessage(IReadOnlyList<ulong> clientIds, FastBufferWriter messageBuffer, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<ulong> | clientIds | The clients to send to, sends to everyone if null |
FastBufferWriter | messageBuffer | The message stream containing the data |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with |
SendUnnamedMessage(ulong, FastBufferWriter, NetworkDelivery)
Sends a unnamed message to a specific client
Declaration
public void SendUnnamedMessage(ulong clientId, FastBufferWriter messageBuffer, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced)
Parameters
Type | Name | Description |
---|---|---|
ulong | clientId | The client to send the message to |
FastBufferWriter | messageBuffer | The message stream containing the data |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with |
SendUnnamedMessageToAll(FastBufferWriter, NetworkDelivery)
Sends unnamed message to all clients
Declaration
public void SendUnnamedMessageToAll(FastBufferWriter messageBuffer, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | messageBuffer | The message stream containing the data |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with |
UnregisterNamedMessageHandler(string)
Unregisters a named message handler.
Declaration
public void UnregisterNamedMessageHandler(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the message. |
Events
OnUnnamedMessage
Event invoked when unnamed messages arrive
Declaration
public event CustomMessagingManager.UnnamedMessageDelegate OnUnnamedMessage
Event Type
Type | Description |
---|---|
CustomMessagingManager.UnnamedMessageDelegate |