NetManager Class |
LiteNetLib |
Main class for all network operations. Can be used as client and/or server.
Inheritance Hierarchy
Namespace: LiteNetLib
Assembly: LiteNetLib (in LiteNetLib.dll) Version: 1.0.0.0
Syntax
C#
public sealed class NetManager
The NetManager type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | NetManager(INetEventListener, String) |
NetManager constructor with maxConnections = 1 (usable for client)
|
![]() | NetManager(INetEventListener, Int32, String) |
NetManager constructor
|
Properties
Name | Description | |
---|---|---|
![]() | BytesReceived | |
![]() | BytesSent | |
![]() | IsRunning |
Returns true if socket listening and update thread is running
|
![]() | LocalPort |
Local EndPoint (host and port)
|
![]() | PacketsReceived | |
![]() | PacketsSent | |
![]() | PeersCount |
Connected peers count
|
![]() | UpdateTime |
Library logic update and send period in milliseconds
|
Methods
Name | Description | |
---|---|---|
![]() | AddFlowMode | |
![]() | Connect(NetEndPoint) |
Connect to remote host
|
![]() | Connect(String, Int32) |
Connect to remote host
|
![]() | DisconnectPeer(NetPeer) |
Disconnect peer from server
|
![]() | DisconnectPeer(NetPeer, NetDataWriter) |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
|
![]() | DisconnectPeer(NetPeer, Byte) |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
|
![]() | DisconnectPeer(NetPeer, Byte, Int32, Int32) |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
|
![]() | Flush |
Flush all queued packets of all peers
|
![]() | GetFirstPeer |
Get first peer. Usefull for Client mode
|
![]() | GetPeers |
Get copy of current connected peers
|
![]() | GetPeersNonAlloc |
Get copy of current connected peers (without allocations)
|
![]() | PollEvents |
Receive all pending events. Call this in game update code
|
![]() | SendDiscoveryRequest(Byte, Int32) | |
![]() | SendDiscoveryRequest(NetDataWriter, Int32) | |
![]() | SendDiscoveryRequest(Byte, Int32, Int32, Int32) | |
![]() | SendDiscoveryResponse(Byte, NetEndPoint) | |
![]() | SendDiscoveryResponse(NetDataWriter, NetEndPoint) | |
![]() | SendDiscoveryResponse(Byte, Int32, Int32, NetEndPoint) | |
![]() | SendToAll(Byte, SendOptions) |
Send data to all connected peers
|
![]() | SendToAll(NetDataWriter, SendOptions) |
Send data to all connected peers
|
![]() | SendToAll(Byte, SendOptions, NetPeer) |
Send data to all connected peers
|
![]() | SendToAll(NetDataWriter, SendOptions, NetPeer) |
Send data to all connected peers
|
![]() | SendToAll(Byte, Int32, Int32, SendOptions) |
Send data to all connected peers
|
![]() | SendToAll(Byte, Int32, Int32, SendOptions, NetPeer) |
Send data to all connected peers
|
![]() | SendUnconnectedMessage(Byte, NetEndPoint) |
Send message without connection
|
![]() | SendUnconnectedMessage(NetDataWriter, NetEndPoint) |
Send message without connection
|
![]() | SendUnconnectedMessage(Byte, Int32, Int32, NetEndPoint) |
Send message without connection
|
![]() | Start |
Start logic thread and listening on available port
|
![]() | Start(Int32) |
Start logic thread and listening on selected port
|
![]() | Stop |
Force closes connection and stop all threads.
|
Fields
Name | Description | |
---|---|---|
![]() | ConnectKey |
Current connection key
|
![]() | DisconnectTimeout |
If NetManager doesn't receive any packet from remote peer during this time then connection will be closed
(including library internal keepalive packets)
|
![]() | DiscoveryEnabled |
Allows receive DiscoveryRequests
|
![]() | MaxConnectAttempts |
Maximum connection attempts before client stops and call disconnect event.
|
![]() | MergeEnabled |
Merge small packets into one before sending to reduce outgoing packets count. (May increase a bit outgoing data size)
|
![]() | NatPunchEnabled |
Enable nat punch messages
|
![]() | NatPunchModule |
NatPunchModule for NAT hole punching operations
|
![]() | PingInterval |
Interval for latency detection and checking connection
|
![]() | ReconnectDelay |
Delay betwen initial connection attempts
|
![]() | ReuseAddress |
Enables socket option "ReuseAddress" for specific purposes
|
![]() | SimulateLatency |
Simulate latency by holding packets for random time. (Works only in DEBUG mode)
|
![]() | SimulatePacketLoss |
Simulate packet loss by dropping random amout of packets. (Works only in DEBUG mode)
|
![]() | SimulationMaxLatency |
Maximum simulated latency
|
![]() | SimulationMinLatency |
Minimum simulated latency
|
![]() | SimulationPacketLossChance |
Chance of packet loss when simulation enabled. value in percents (1 - 100).
|
![]() | UnconnectedMessagesEnabled |
Enable messages receiving without connection. (with SendUnconnectedMessage method)
|
![]() | UnsyncedEvents |
Experimental feature. Events automatically will be called without PollEvents method from another thread
|
See Also