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.
Namespace: Unity.Netcode
Syntax
public class CustomMessagingManager
Methods
RegisterNamedMessageHandler(String, CustomMessagingManager.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<UInt64>, 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<UInt64> | 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, UInt64, 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 |
UInt64 | 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<UInt64>, 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<UInt64> | 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(UInt64, 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 |
---|---|---|
UInt64 | 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 |