My Project
|
Main class for all network operations. Can be used as client and/or server. More...
Classes | |
struct | NetPeerEnumerator |
Public Member Functions | |
NetPeer | GetPeerById (int id) |
Gets peer by peer id. | |
NetManager (INetEventListener listener, PacketLayerBase extraPacketLayer=null) | |
NetManager constructor. | |
void | ManualUpdate (int elapsedMilliseconds) |
Update and send logic. Use this only when NetManager started in manual mode. | |
void | ManualReceive () |
Receive logic. It will call Receive events immediately without need to use PollEvents or UnsyncedEvents Use this only when NetManager started in manual mode. | |
void | SendToAll (NetDataWriter writer, DeliveryMethod options) |
Send data to all connected peers (channel - 0) | |
void | SendToAll (byte[] data, DeliveryMethod options) |
Send data to all connected peers (channel - 0) | |
void | SendToAll (byte[] data, int start, int length, DeliveryMethod options) |
Send data to all connected peers (channel - 0) | |
void | SendToAll (NetDataWriter writer, byte channelNumber, DeliveryMethod options) |
Send data to all connected peers. | |
void | SendToAll (byte[] data, byte channelNumber, DeliveryMethod options) |
Send data to all connected peers. | |
void | SendToAll (byte[] data, int start, int length, byte channelNumber, DeliveryMethod options) |
Send data to all connected peers. | |
void | SendToAll (NetDataWriter writer, DeliveryMethod options, NetPeer excludePeer) |
Send data to all connected peers (channel - 0) | |
void | SendToAll (byte[] data, DeliveryMethod options, NetPeer excludePeer) |
Send data to all connected peers (channel - 0) | |
void | SendToAll (byte[] data, int start, int length, DeliveryMethod options, NetPeer excludePeer) |
Send data to all connected peers (channel - 0) | |
void | SendToAll (NetDataWriter writer, byte channelNumber, DeliveryMethod options, NetPeer excludePeer) |
Send data to all connected peers. | |
void | SendToAll (byte[] data, byte channelNumber, DeliveryMethod options, NetPeer excludePeer) |
Send data to all connected peers. | |
void | SendToAll (byte[] data, int start, int length, byte channelNumber, DeliveryMethod options, NetPeer excludePeer) |
Send data to all connected peers. | |
bool | Start () |
Start logic thread and listening on available port. | |
bool | Start (IPAddress addressIPv4, IPAddress addressIPv6, int port) |
Start logic thread and listening on selected port. | |
bool | Start (string addressIPv4, string addressIPv6, int port) |
Start logic thread and listening on selected port. | |
bool | Start (int port) |
Start logic thread and listening on selected port. | |
bool | StartInManualMode (IPAddress addressIPv4, IPAddress addressIPv6, int port) |
Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers. | |
bool | StartInManualMode (string addressIPv4, string addressIPv6, int port) |
Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers. | |
bool | StartInManualMode (int port) |
Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers. | |
bool | SendUnconnectedMessage (byte[] message, IPEndPoint remoteEndPoint) |
Send message without connection. | |
bool | SendUnconnectedMessage (NetDataWriter writer, IPEndPoint remoteEndPoint) |
Send message without connection. | |
bool | SendUnconnectedMessage (byte[] message, int start, int length, IPEndPoint remoteEndPoint) |
Send message without connection. | |
bool | SendBroadcast (NetDataWriter writer, int port) |
bool | SendBroadcast (byte[] data, int port) |
bool | SendBroadcast (byte[] data, int start, int length, int port) |
void | TriggerUpdate () |
Triggers update and send logic immediately (works asynchronously) | |
void | PollEvents () |
Receive all pending events. Call this in game update code. | |
NetPeer | Connect (string address, int port, string key) |
Connect to remote host. | |
NetPeer | Connect (string address, int port, NetDataWriter connectionData) |
Connect to remote host. | |
NetPeer | Connect (IPEndPoint target, string key) |
Connect to remote host. | |
NetPeer | Connect (IPEndPoint target, NetDataWriter connectionData) |
Connect to remote host. | |
void | Stop () |
Force closes connection and stop all threads. | |
void | Stop (bool sendDisconnectMessages) |
Force closes connection and stop all threads. | |
int | GetPeersCount (ConnectionState peerState) |
Return peers count with connection state. | |
void | GetPeersNonAlloc (List< NetPeer > peers, ConnectionState peerState) |
Get copy of peers (without allocations) | |
void | DisconnectAll () |
Disconnect all peers without any additional data. | |
void | DisconnectAll (byte[] data, int start, int count) |
Disconnect all peers with shutdown message. | |
void | DisconnectPeerForce (NetPeer peer) |
Immediately disconnect peer from server without additional data. | |
void | DisconnectPeer (NetPeer peer) |
Disconnect peer from server. | |
void | DisconnectPeer (NetPeer peer, byte[] data) |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8) | |
void | DisconnectPeer (NetPeer peer, NetDataWriter writer) |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8) | |
void | DisconnectPeer (NetPeer peer, byte[] data, int start, int count) |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8) | |
void | CreateNtpRequest (IPEndPoint endPoint) |
Create the requests for NTP server. | |
void | CreateNtpRequest (string ntpServerAddress, int port) |
Create the requests for NTP server. | |
void | CreateNtpRequest (string ntpServerAddress) |
Create the requests for NTP server (default port) | |
NetPeerEnumerator | GetEnumerator () |
Public Attributes | |
bool | UnconnectedMessagesEnabled = false |
Enable messages receiving without connection. (with SendUnconnectedMessage method) | |
bool | NatPunchEnabled = false |
Enable nat punch messages. | |
int | UpdateTime = 15 |
Library logic update and send period in milliseconds. | |
int | PingInterval = 1000 |
Interval for latency detection and checking connection. | |
int | DisconnectTimeout = 5000 |
If NetManager doesn't receive any packet from remote peer during this time then connection will be closed (including library internal keepalive packets) | |
bool | SimulatePacketLoss = false |
Simulate packet loss by dropping random amount of packets. (Works only in DEBUG mode) | |
bool | SimulateLatency = false |
Simulate latency by holding packets for random time. (Works only in DEBUG mode) | |
int | SimulationPacketLossChance = 10 |
Chance of packet loss when simulation enabled. value in percents (1 - 100). | |
int | SimulationMinLatency = 30 |
Minimum simulated latency. | |
int | SimulationMaxLatency = 100 |
Maximum simulated latency. | |
bool | UnsyncedEvents = false |
Events automatically will be called without PollEvents method from another thread. | |
bool | UnsyncedReceiveEvent = false |
If true - receive event will be called from "receive" thread immediately otherwise on PollEvents call. | |
bool | UnsyncedDeliveryEvent = false |
If true - delivery event will be called from "receive" thread immediately otherwise on PollEvents call. | |
bool | BroadcastReceiveEnabled = false |
Allows receive broadcast packets. | |
int | ReconnectDelay = 500 |
Delay between initial connection attempts. | |
int | MaxConnectAttempts = 10 |
Maximum connection attempts before client stops and call disconnect event. | |
bool | ReuseAddress = false |
Enables socket option "ReuseAddress" for specific purposes. | |
readonly NetStatistics | Statistics |
Statistics of all connections. | |
bool | EnableStatistics = false |
Toggles the collection of network statistics for the instance and all known peers. | |
readonly NatPunchModule | NatPunchModule |
NatPunchModule for NAT hole punching operations. | |
bool | AutoRecycle |
Automatically recycle NetPacketReader after OnReceive event. | |
IPv6Mode | IPv6Enabled = IPv6Mode.SeparateSocket |
IPv6 support. | |
int | MtuOverride = 0 |
Override MTU for all new peers registered in this NetManager, will ignores MTU Discovery! | |
bool | UseSafeMtu = false |
Sets initial MTU to lowest possible value according to RFC1191 (576 bytes) | |
bool | DisconnectOnUnreachable = false |
Disconnect peers if HostUnreachable or NetworkUnreachable spawned (old behaviour 0.9.x was true) | |
Properties | |
bool | IsRunning [get] |
Returns true if socket listening and update thread is running. | |
int | LocalPort [get] |
Local EndPoint (host and port) | |
NetPeer | FirstPeer [get] |
First peer. Useful for Client mode. | |
byte | ChannelsCount [get, set] |
QoS channel count per message type (value must be between 1 and 64 channels) | |
List< NetPeer > | ConnectedPeerList [get] |
Returns connected peers list (with internal cached list) | |
int | ConnectedPeersCount [get] |
Returns connected peers count. | |
int | ExtraPacketSizeForLayer [get] |
Main class for all network operations. Can be used as client and/or server.
|
inline |
NetManager constructor.
listener | Network events listener (also can implement IDeliveryEventListener) |
extraPacketLayer | Extra processing of packages, like CRC checksum or encryption. All connected NetManagers must have same layer. |
|
inline |
Connect to remote host.
target | Server end point (ip and port) |
connectionData | Additional data for remote peer |
InvalidOperationException | Manager is not running. Call Start() |
|
inline |
Connect to remote host.
target | Server end point (ip and port) |
key | Connection key |
InvalidOperationException | Manager is not running. Call Start() |
|
inline |
Connect to remote host.
address | Server IP or hostname |
port | Server Port |
connectionData | Additional data for remote peer |
InvalidOperationException | Manager is not running. Call Start() |
|
inline |
Connect to remote host.
address | Server IP or hostname |
port | Server Port |
key | Connection key |
InvalidOperationException | Manager is not running. Call Start() |
|
inline |
Create the requests for NTP server.
endPoint | NTP Server address. |
|
inline |
Create the requests for NTP server (default port)
ntpServerAddress | NTP Server address. |
|
inline |
Create the requests for NTP server.
ntpServerAddress | NTP Server address. |
port | port |
|
inline |
Disconnect all peers with shutdown message.
data | Data to send (must be less or equal MTU) |
start | Data start |
count | Data count |
|
inline |
Disconnect peer from server.
peer | peer to disconnect |
|
inline |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
peer | peer to disconnect |
data | additional data |
|
inline |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
peer | peer to disconnect |
data | additional data |
start | data start |
count | data length |
|
inline |
Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
peer | peer to disconnect |
writer | additional data |
|
inline |
Immediately disconnect peer from server without additional data.
peer | peer to disconnect |
|
inline |
Gets peer by peer id.
id | id of peer |
|
inline |
Return peers count with connection state.
peerState | peer connection state (you can use as bit flags) |
|
inline |
Get copy of peers (without allocations)
peers | List that will contain result |
peerState | State of peers |
|
inline |
Update and send logic. Use this only when NetManager started in manual mode.
elapsedMilliseconds | elapsed milliseconds since last update call |
|
inline |
Send data to all connected peers.
data | Data |
channelNumber | Number of channel (from 0 to channelsCount - 1) |
options | Send options (reliable, unreliable, etc.) |
|
inline |
Send data to all connected peers.
data | Data |
channelNumber | Number of channel (from 0 to channelsCount - 1) |
options | Send options (reliable, unreliable, etc.) |
excludePeer | Excluded peer |
|
inline |
Send data to all connected peers (channel - 0)
data | Data |
options | Send options (reliable, unreliable, etc.) |
|
inline |
Send data to all connected peers (channel - 0)
data | Data |
options | Send options (reliable, unreliable, etc.) |
excludePeer | Excluded peer |
|
inline |
Send data to all connected peers.
data | Data |
start | Start of data |
length | Length of data |
channelNumber | Number of channel (from 0 to channelsCount - 1) |
options | Send options (reliable, unreliable, etc.) |
|
inline |
Send data to all connected peers.
data | Data |
start | Start of data |
length | Length of data |
channelNumber | Number of channel (from 0 to channelsCount - 1) |
options | Send options (reliable, unreliable, etc.) |
excludePeer | Excluded peer |
|
inline |
Send data to all connected peers (channel - 0)
data | Data |
start | Start of data |
length | Length of data |
options | Send options (reliable, unreliable, etc.) |
|
inline |
Send data to all connected peers (channel - 0)
data | Data |
start | Start of data |
length | Length of data |
options | Send options (reliable, unreliable, etc.) |
excludePeer | Excluded peer |
|
inline |
Send data to all connected peers.
writer | DataWriter with data |
channelNumber | Number of channel (from 0 to channelsCount - 1) |
options | Send options (reliable, unreliable, etc.) |
|
inline |
Send data to all connected peers.
writer | DataWriter with data |
channelNumber | Number of channel (from 0 to channelsCount - 1) |
options | Send options (reliable, unreliable, etc.) |
excludePeer | Excluded peer |
|
inline |
Send data to all connected peers (channel - 0)
writer | DataWriter with data |
options | Send options (reliable, unreliable, etc.) |
|
inline |
Send data to all connected peers (channel - 0)
writer | DataWriter with data |
options | Send options (reliable, unreliable, etc.) |
excludePeer | Excluded peer |
|
inline |
Send message without connection.
message | Raw data |
start | data start |
length | data length |
remoteEndPoint | Packet destination |
|
inline |
Send message without connection.
message | Raw data |
remoteEndPoint | Packet destination |
|
inline |
Send message without connection.
writer | Data serializer |
remoteEndPoint | Packet destination |
|
inline |
Start logic thread and listening on selected port.
port | port to listen |
|
inline |
Start logic thread and listening on selected port.
addressIPv4 | bind to specific ipv4 address |
addressIPv6 | bind to specific ipv6 address |
port | port to listen |
|
inline |
Start logic thread and listening on selected port.
addressIPv4 | bind to specific ipv4 address |
addressIPv6 | bind to specific ipv6 address |
port | port to listen |
|
inline |
Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers.
port | port to listen |
|
inline |
Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers.
addressIPv4 | bind to specific ipv4 address |
addressIPv6 | bind to specific ipv6 address |
port | port to listen |
|
inline |
Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers.
addressIPv4 | bind to specific ipv4 address |
addressIPv6 | bind to specific ipv6 address |
port | port to listen |
|
inline |
Force closes connection and stop all threads.
sendDisconnectMessages | Send disconnect messages |