Class NetManager
More feature rich network manager with adjustable channels count
Inherited Members
Namespace: LiteNetLib
Assembly: LiteNetLib.dll
Syntax
public class NetManager : LiteNetManager, IEnumerable<LiteNetPeer>, IEnumerable
Constructors
NetManager(INetEventListener, PacketLayerBase)
Declaration
public NetManager(INetEventListener listener, PacketLayerBase extraPacketLayer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| INetEventListener | listener | |
| PacketLayerBase | extraPacketLayer |
Properties
ChannelsCount
QoS channel count per message type (value must be between 1 and 64 channels)
Declaration
public byte ChannelsCount { get; set; }
Property Value
| Type | Description |
|---|---|
| byte |
Methods
Connect(IPEndPoint, NetDataWriter)
Connect to remote host
Declaration
public NetPeer Connect(IPEndPoint target, NetDataWriter connectionData)
Parameters
| Type | Name | Description |
|---|---|---|
| IPEndPoint | target | Server end point (ip and port) |
| NetDataWriter | connectionData | Additional data for remote peer |
Returns
| Type | Description |
|---|---|
| NetPeer | New NetPeer if new connection, Old NetPeer if already connected, null peer if there is ConnectionRequest awaiting |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Manager is not running. Call Start() |
Connect(IPEndPoint, ReadOnlySpan<byte>)
Connect to remote host
Declaration
public NetPeer Connect(IPEndPoint target, ReadOnlySpan<byte> connectionData)
Parameters
| Type | Name | Description |
|---|---|---|
| IPEndPoint | target | Server end point (ip and port) |
| ReadOnlySpan<byte> | connectionData | Additional data for remote peer |
Returns
| Type | Description |
|---|---|
| NetPeer | New NetPeer if new connection, Old NetPeer if already connected, null peer if there is ConnectionRequest awaiting |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Manager is not running. Call Start() |
Connect(IPEndPoint, string)
Connect to remote host
Declaration
public NetPeer Connect(IPEndPoint target, string key)
Parameters
| Type | Name | Description |
|---|---|---|
| IPEndPoint | target | Server end point (ip and port) |
| string | key | Connection key |
Returns
| Type | Description |
|---|---|
| NetPeer | New NetPeer if new connection, Old NetPeer if already connected, null peer if there is ConnectionRequest awaiting |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Manager is not running. Call Start() |
Connect(string, int, NetDataWriter)
Connect to remote host
Declaration
public NetPeer Connect(string address, int port, NetDataWriter connectionData)
Parameters
| Type | Name | Description |
|---|---|---|
| string | address | Server IP or hostname |
| int | port | Server Port |
| NetDataWriter | connectionData | Additional data for remote peer |
Returns
| Type | Description |
|---|---|
| NetPeer | New NetPeer if new connection, Old NetPeer if already connected, null peer if there is ConnectionRequest awaiting |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Manager is not running. Call Start() |
Connect(string, int, string)
Connect to remote host
Declaration
public NetPeer Connect(string address, int port, string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | address | Server IP or hostname |
| int | port | Server Port |
| string | key | Connection key |
Returns
| Type | Description |
|---|---|
| NetPeer | New NetPeer if new connection, Old NetPeer if already connected, null peer if there is ConnectionRequest awaiting |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Manager is not running. Call Start() |
CreateIncomingPeer(ConnectionRequest, int)
Declaration
protected override LiteNetPeer CreateIncomingPeer(ConnectionRequest request, int id)
Parameters
| Type | Name | Description |
|---|---|---|
| ConnectionRequest | request | |
| int | id |
Returns
| Type | Description |
|---|---|
| LiteNetPeer |
Overrides
CreateNtpRequest(IPEndPoint)
Create the requests for NTP server
Declaration
public void CreateNtpRequest(IPEndPoint endPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| IPEndPoint | endPoint | NTP Server address. |
CreateNtpRequest(string)
Create the requests for NTP server (default port)
Declaration
public void CreateNtpRequest(string ntpServerAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ntpServerAddress | NTP Server address. |
CreateNtpRequest(string, int)
Create the requests for NTP server
Declaration
public void CreateNtpRequest(string ntpServerAddress, int port)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ntpServerAddress | NTP Server address. |
| int | port | port |
CreateOutgoingPeer(IPEndPoint, int, byte, ReadOnlySpan<byte>)
Declaration
protected override LiteNetPeer CreateOutgoingPeer(IPEndPoint remoteEndPoint, int id, byte connectNum, ReadOnlySpan<byte> connectData)
Parameters
| Type | Name | Description |
|---|---|---|
| IPEndPoint | remoteEndPoint | |
| int | id | |
| byte | connectNum | |
| ReadOnlySpan<byte> | connectData |
Returns
| Type | Description |
|---|---|
| LiteNetPeer |
Overrides
CreateRejectPeer(IPEndPoint, int)
Declaration
protected override LiteNetPeer CreateRejectPeer(IPEndPoint remoteEndPoint, int id)
Parameters
| Type | Name | Description |
|---|---|---|
| IPEndPoint | remoteEndPoint | |
| int | id |
Returns
| Type | Description |
|---|---|
| LiteNetPeer |
Overrides
ProcessEvent(NetEvent)
Declaration
protected override void ProcessEvent(NetEvent evt)
Parameters
| Type | Name | Description |
|---|---|---|
| NetEvent | evt |
Overrides
ProcessNtpRequests(float)
Declaration
protected override void ProcessNtpRequests(float elapsedMilliseconds)
Parameters
| Type | Name | Description |
|---|---|---|
| float | elapsedMilliseconds |
Overrides
SendToAll(NetDataWriter, byte, DeliveryMethod)
Send data to all connected peers
Declaration
public void SendToAll(NetDataWriter writer, byte channelNumber, DeliveryMethod options)
Parameters
| Type | Name | Description |
|---|---|---|
| NetDataWriter | writer | DataWriter with data |
| byte | channelNumber | Number of channel (from 0 to channelsCount - 1) |
| DeliveryMethod | options | Send options (reliable, unreliable, etc.) |
SendToAll(NetDataWriter, byte, DeliveryMethod, LiteNetPeer)
Send data to all connected peers
Declaration
public void SendToAll(NetDataWriter writer, byte channelNumber, DeliveryMethod options, LiteNetPeer excludePeer)
Parameters
| Type | Name | Description |
|---|---|---|
| NetDataWriter | writer | DataWriter with data |
| byte | channelNumber | Number of channel (from 0 to channelsCount - 1) |
| DeliveryMethod | options | Send options (reliable, unreliable, etc.) |
| LiteNetPeer | excludePeer | Excluded peer |
SendToAll(byte[], byte, DeliveryMethod)
Send data to all connected peers
Declaration
public void SendToAll(byte[] data, byte channelNumber, DeliveryMethod options)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | Data |
| byte | channelNumber | Number of channel (from 0 to channelsCount - 1) |
| DeliveryMethod | options | Send options (reliable, unreliable, etc.) |
SendToAll(byte[], byte, DeliveryMethod, LiteNetPeer)
Send data to all connected peers
Declaration
public void SendToAll(byte[] data, byte channelNumber, DeliveryMethod options, LiteNetPeer excludePeer)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | Data |
| byte | channelNumber | Number of channel (from 0 to channelsCount - 1) |
| DeliveryMethod | options | Send options (reliable, unreliable, etc.) |
| LiteNetPeer | excludePeer | Excluded peer |
SendToAll(byte[], int, int, byte, DeliveryMethod, LiteNetPeer)
Send data to all connected peers
Declaration
public void SendToAll(byte[] data, int start, int length, byte channelNumber, DeliveryMethod options, LiteNetPeer excludePeer)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | Data |
| int | start | Start of data |
| int | length | Length of data |
| byte | channelNumber | Number of channel (from 0 to channelsCount - 1) |
| DeliveryMethod | options | Send options (reliable, unreliable, etc.) |
| LiteNetPeer | excludePeer | Excluded peer |