Class NetworkChannel
Represents a channel in the network which has a registry of packets it recognises.
Namespace: FNNLib.Messaging
Assembly: FNNLib.dll
Syntax
[Serializable]
public sealed class NetworkChannel
Constructors
| Improve this Doc View SourceNetworkChannel(ChannelType)
Create a new network channel.
Declaration
public NetworkChannel(ChannelType type)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelType | type | Network channel type. |
Fields
| Improve this Doc View SourcechannelType
The channel type. Used for URDP transports.
Declaration
public ChannelType channelType
Field Value
| Type | Description |
|---|---|
| ChannelType |
Reliable
Default reliable channel.
Declaration
public static readonly NetworkChannel Reliable
Field Value
| Type | Description |
|---|---|
| NetworkChannel |
ReliableSequenced
Default reliable sequenced channel.
Declaration
public static readonly NetworkChannel ReliableSequenced
Field Value
| Type | Description |
|---|---|
| NetworkChannel |
Unreliable
Default unreliable channel.
Declaration
public static readonly NetworkChannel Unreliable
Field Value
| Type | Description |
|---|---|
| NetworkChannel |
Properties
| Improve this Doc View SourceID
Get the channel ID. Mostly for internal use.
Declaration
public int ID { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Methods
| Improve this Doc View SourceClientSend(Int32, NetworkWriter)
Send a generic message to the server.
Declaration
public void ClientSend(int messageId, NetworkWriter packetWriter)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | messageId | |
| NetworkWriter | packetWriter |
ClientSend<T>(T)
Send a typed message to the server.
Declaration
public void ClientSend<T>(T packet)
where T : ISerializable
Parameters
| Type | Name | Description |
|---|---|---|
| T | packet | The message to send. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the message. |
Exceptions
| Type | Condition |
|---|---|
| Exception | The type was not found in the registry. |
GetFactory()
Get a factory for the next message ID.
Declaration
public NetworkChannel.MessageFactory GetFactory()
Returns
| Type | Description |
|---|---|
| NetworkChannel.MessageFactory |
GetFactory(Int32)
Get a factory for the current ID.
Declaration
public NetworkChannel.MessageFactory GetFactory(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | id |
Returns
| Type | Description |
|---|---|
| NetworkChannel.MessageFactory |
GetNextID()
Get the next available ID from the internal counter.
Declaration
public int GetNextID()
Returns
| Type | Description |
|---|---|
| Int32 | The next available ID |
HandleBuffered(BufferedPacket, Boolean)
Handle a buffered packet.
Declaration
public void HandleBuffered(BufferedPacket packet, bool server)
Parameters
| Type | Name | Description |
|---|---|---|
| BufferedPacket | packet | The buffered packet |
| Boolean | server | Whether or not this is handled on serverside. |
HandleIncoming(UInt64, NetworkReader, Boolean)
Handle an incoming packet.
Declaration
public void HandleIncoming(ulong clientID, NetworkReader reader, bool server)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt64 | clientID | |
| NetworkReader | reader | |
| Boolean | server |
ResetChannel()
Fully reset channel, clearing registries.
Declaration
public void ResetChannel()
ServerSend(List<UInt64>, Int32, NetworkWriter)
Send a generic message to a list of clients.
Declaration
public void ServerSend(List<ulong> clientIds, int messageId, NetworkWriter packetWriter)
Parameters
| Type | Name | Description |
|---|---|---|
| List<UInt64> | clientIds | The clients to send to. |
| Int32 | messageId | The message ID. |
| NetworkWriter | packetWriter | Writer containing message information. |
Exceptions
| Type | Condition |
|---|---|
| Exception |
ServerSend(List<UInt64>, Int32, NetworkWriter, UInt64)
Send a generic message to a list of clients, excluding one.
Declaration
public void ServerSend(List<ulong> clientIds, int messageId, NetworkWriter packetWriter, ulong excludedClient)
Parameters
| Type | Name | Description |
|---|---|---|
| List<UInt64> | clientIds | The clients to send to. |
| Int32 | messageId | The message ID. |
| NetworkWriter | packetWriter | Writer containing message information. |
| UInt64 | excludedClient | The client to exclude. |
Exceptions
| Type | Condition |
|---|---|
| Exception |
ServerSend(Int32, NetworkWriter)
Send a generic message to all clients.
Declaration
public void ServerSend(int messageId, NetworkWriter packetWriter)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | messageId | The message ID. |
| NetworkWriter | packetWriter | Writer containing message information |
ServerSend(Int32, NetworkWriter, UInt64)
Send a generic message to all clients excluding one.
Declaration
public void ServerSend(int messageId, NetworkWriter packetWriter, ulong excludedClient)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | messageId | The message ID. |
| NetworkWriter | packetWriter | Writer containing message information |
| UInt64 | excludedClient | Client to exclude. |
ServerSend(UInt64, Int32, NetworkWriter)
Send a generic message to a client.
Declaration
public void ServerSend(ulong clientId, int messageId, NetworkWriter packetWriter)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt64 | clientId | The client to send to. |
| Int32 | messageId | The message ID. |
| NetworkWriter | packetWriter | Writer containing message information. |
Exceptions
| Type | Condition |
|---|---|
| Exception |
ServerSend<T>(T)
Send a typed message to all clients.
Declaration
public void ServerSend<T>(T packet)
where T : ISerializable
Parameters
| Type | Name | Description |
|---|---|---|
| T | packet | The message to send. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the message |
ServerSend<T>(T, UInt64)
Send a typed message to all clients excluding one.
Declaration
public void ServerSend<T>(T packet, ulong excludedClient)
where T : ISerializable
Parameters
| Type | Name | Description |
|---|---|---|
| T | packet | The message to send. |
| UInt64 | excludedClient | Client to exclude |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the message |
ServerSend<T>(List<UInt64>, T)
Send a typed message to a list of clients.
Declaration
public void ServerSend<T>(List<ulong> clientIds, T packet)
where T : ISerializable
Parameters
| Type | Name | Description |
|---|---|---|
| List<UInt64> | clientIds | The clients to send to. |
| T | packet | The message to send. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the message. |
Exceptions
| Type | Condition |
|---|---|
| Exception |
ServerSend<T>(List<UInt64>, T, UInt64)
Sends a typed message to a list of clients, excluding one.
Declaration
public void ServerSend<T>(List<ulong> clientIds, T packet, ulong excludedClient)
where T : ISerializable
Parameters
| Type | Name | Description |
|---|---|---|
| List<UInt64> | clientIds | The clients to send to. |
| T | packet | The message to send. |
| UInt64 | excludedClient | The client to exclude. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the message |
Exceptions
| Type | Condition |
|---|---|
| Exception |
ServerSend<T>(UInt64, T)
Send a typed message to a client.
Declaration
public void ServerSend<T>(ulong clientId, T packet)
where T : ISerializable
Parameters
| Type | Name | Description |
|---|---|---|
| UInt64 | clientId | The client to send to. |
| T | packet | The message to send. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the message. |
Exceptions
| Type | Condition |
|---|---|
| Exception | Message type not in the registry. |