NetManager Class

LiteNetLib

NetManager Class

LiteNetLib
Main class for all network operations. Can be used as client and/or server.
Inheritance Hierarchy

SystemObject  LiteNetLibNetManager

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

  NameDescription
Public methodNetManager(INetEventListener, String)
NetManager constructor with maxConnections = 1 (usable for client)
Public methodNetManager(INetEventListener, Int32, String)
NetManager constructor
Top
Properties

  NameDescription
Public propertyBytesReceived
Public propertyBytesSent
Public propertyIsRunning
Returns true if socket listening and update thread is running
Public propertyLocalPort
Local EndPoint (host and port)
Public propertyPacketsReceived
Public propertyPacketsSent
Public propertyPeersCount
Connected peers count
Public propertyUpdateTime
Library logic update and send period in milliseconds
Top
Methods

  NameDescription
Public methodAddFlowMode
Public methodConnect(NetEndPoint)
Connect to remote host
Public methodConnect(String, Int32)
Connect to remote host
Public methodDisconnectPeer(NetPeer)
Disconnect peer from server
Public methodDisconnectPeer(NetPeer, NetDataWriter)
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
Public methodDisconnectPeer(NetPeer, Byte)
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
Public methodDisconnectPeer(NetPeer, Byte, Int32, Int32)
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
Public methodFlush
Flush all queued packets of all peers
Public methodGetFirstPeer
Get first peer. Usefull for Client mode
Public methodGetPeers
Get copy of current connected peers
Public methodGetPeersNonAlloc
Get copy of current connected peers (without allocations)
Public methodPollEvents
Receive all pending events. Call this in game update code
Public methodSendDiscoveryRequest(Byte, Int32)
Public methodSendDiscoveryRequest(NetDataWriter, Int32)
Public methodSendDiscoveryRequest(Byte, Int32, Int32, Int32)
Public methodSendDiscoveryResponse(Byte, NetEndPoint)
Public methodSendDiscoveryResponse(NetDataWriter, NetEndPoint)
Public methodSendDiscoveryResponse(Byte, Int32, Int32, NetEndPoint)
Public methodSendToAll(Byte, SendOptions)
Send data to all connected peers
Public methodSendToAll(NetDataWriter, SendOptions)
Send data to all connected peers
Public methodSendToAll(Byte, SendOptions, NetPeer)
Send data to all connected peers
Public methodSendToAll(NetDataWriter, SendOptions, NetPeer)
Send data to all connected peers
Public methodSendToAll(Byte, Int32, Int32, SendOptions)
Send data to all connected peers
Public methodSendToAll(Byte, Int32, Int32, SendOptions, NetPeer)
Send data to all connected peers
Public methodSendUnconnectedMessage(Byte, NetEndPoint)
Send message without connection
Public methodSendUnconnectedMessage(NetDataWriter, NetEndPoint)
Send message without connection
Public methodSendUnconnectedMessage(Byte, Int32, Int32, NetEndPoint)
Send message without connection
Public methodStart
Start logic thread and listening on available port
Public methodStart(Int32)
Start logic thread and listening on selected port
Public methodStop
Force closes connection and stop all threads.
Top
Fields

  NameDescription
Public fieldConnectKey
Current connection key
Public fieldDisconnectTimeout
If NetManager doesn't receive any packet from remote peer during this time then connection will be closed (including library internal keepalive packets)
Public fieldDiscoveryEnabled
Allows receive DiscoveryRequests
Public fieldMaxConnectAttempts
Maximum connection attempts before client stops and call disconnect event.
Public fieldMergeEnabled
Merge small packets into one before sending to reduce outgoing packets count. (May increase a bit outgoing data size)
Public fieldNatPunchEnabled
Enable nat punch messages
Public fieldNatPunchModule
NatPunchModule for NAT hole punching operations
Public fieldPingInterval
Interval for latency detection and checking connection
Public fieldReconnectDelay
Delay betwen initial connection attempts
Public fieldReuseAddress
Enables socket option "ReuseAddress" for specific purposes
Public fieldSimulateLatency
Simulate latency by holding packets for random time. (Works only in DEBUG mode)
Public fieldSimulatePacketLoss
Simulate packet loss by dropping random amout of packets. (Works only in DEBUG mode)
Public fieldSimulationMaxLatency
Maximum simulated latency
Public fieldSimulationMinLatency
Minimum simulated latency
Public fieldSimulationPacketLossChance
Chance of packet loss when simulation enabled. value in percents (1 - 100).
Public fieldUnconnectedMessagesEnabled
Enable messages receiving without connection. (with SendUnconnectedMessage method)
Public fieldUnsyncedEvents
Experimental feature. Events automatically will be called without PollEvents method from another thread
Top
See Also

Reference