diff --git a/LiteNetLib/NetManager.cs b/LiteNetLib/NetManager.cs index 873fed7b..9a452619 100644 --- a/LiteNetLib/NetManager.cs +++ b/LiteNetLib/NetManager.cs @@ -505,7 +505,8 @@ internal int SendRaw(byte[] message, int start, int length, IPEndPoint remoteEnd case SocketError.HostUnreachable: case SocketError.NetworkUnreachable: - if (DisconnectOnUnreachable && TryGetPeer(remoteEndPoint, out var fromPeer)) + NetPeer fromPeer; + if (DisconnectOnUnreachable && TryGetPeer(remoteEndPoint, out fromPeer)) { DisconnectPeerForce( fromPeer, diff --git a/LiteNetLibSampleUnity/Assets/LiteNetLib.dll b/LiteNetLibSampleUnity/Assets/LiteNetLib.dll index 5190cb7c..17ca8ee9 100644 Binary files a/LiteNetLibSampleUnity/Assets/LiteNetLib.dll and b/LiteNetLibSampleUnity/Assets/LiteNetLib.dll differ diff --git a/LiteNetLibSampleUnity/Assets/LiteNetLib.xml b/LiteNetLibSampleUnity/Assets/LiteNetLib.xml index e4671515..9a53889d 100644 --- a/LiteNetLibSampleUnity/Assets/LiteNetLib.xml +++ b/LiteNetLibSampleUnity/Assets/LiteNetLib.xml @@ -295,6 +295,11 @@ First peer. Useful for Client mode + + + Disconnect peers if HostUnreachable or NetworkUnreachable spawned (old behaviour 0.9.x was true) + + QoS channel count per message type (value must be between 1 and 64 channels) @@ -577,4 +582,795 @@ Force closes connection and stop all threads. - + + Force closes connection and stop all threads. + + Send disconnect messages + + + + Return peers count with connection state + + peer connection state (you can use as bit flags) + peers count + + + + Get copy of peers (without allocations) + + List that will contain result + State of peers + + + + Disconnect all peers without any additional data + + + + + Disconnect all peers with shutdown message + + Data to send (must be less or equal MTU) + Data start + Data count + + + + Immediately disconnect peer from server without additional data + + peer to disconnect + + + + Disconnect peer from server + + peer to disconnect + + + + Disconnect peer from server and send additional data (Size must be less or equal MTU - 8) + + peer to disconnect + additional data + + + + Disconnect peer from server and send additional data (Size must be less or equal MTU - 8) + + peer to disconnect + additional data + + + + Disconnect peer from server and send additional data (Size must be less or equal MTU - 8) + + peer to disconnect + additional data + data start + data length + + + + Create the requests for NTP server + + NTP Server address. + + + + Create the requests for NTP server + + NTP Server address. + port + + + + Create the requests for NTP server (default port) + + NTP Server address. + + + + Peer connection state + + + + + Network peer. Main purpose is sending messages to specific peer. + + + + + Peer ip address and port + + + + + Peer parent NetManager + + + + + Current connection state + + + + + Connection time for internal purposes + + + + + Peer id can be used as key in your dictionary of peers + + + + + Current ping in milliseconds + + + + + Current MTU - Maximum Transfer Unit ( maximum udp packet size without fragmentation ) + + + + + Delta with remote time in ticks (not accurate) + positive - remote time > our time + + + + + Remote UTC time (not accurate) + + + + + Time since last packet received (including internal library packets) + + + + + Application defined object containing data about the connection + + + + + Statistics of peer connection + + + + + Returns packets count in queue for reliable channel + + number of channel 0-63 + type of channel ReliableOrdered or ReliableUnordered + packets count in channel queue + + + + Gets maximum size of packet that will be not fragmented. + + Type of packet that you want send + size in bytes + + + + Send data to peer with delivery event called + + Data + Number of channel (from 0 to channelsCount - 1) + Delivery method (reliable, unreliable, etc.) + User data that will be received in DeliveryEvent + + If you trying to send unreliable packet type + + + + + Send data to peer with delivery event called + + Data + Start of data + Length of data + Number of channel (from 0 to channelsCount - 1) + Delivery method (reliable, unreliable, etc.) + User data that will be received in DeliveryEvent + + If you trying to send unreliable packet type + + + + + Send data to peer with delivery event called + + Data + Number of channel (from 0 to channelsCount - 1) + Delivery method (reliable, unreliable, etc.) + User data that will be received in DeliveryEvent + + If you trying to send unreliable packet type + + + + + Send data to peer (channel - 0) + + Data + Send options (reliable, unreliable, etc.) + + If size exceeds maximum limit: + MTU - headerSize bytes for Unreliable + Fragment count exceeded ushort.MaxValue + + + + + Send data to peer (channel - 0) + + DataWriter with data + Send options (reliable, unreliable, etc.) + + If size exceeds maximum limit: + MTU - headerSize bytes for Unreliable + Fragment count exceeded ushort.MaxValue + + + + + Send data to peer (channel - 0) + + Data + Start of data + Length of data + Send options (reliable, unreliable, etc.) + + If size exceeds maximum limit: + MTU - headerSize bytes for Unreliable + Fragment count exceeded ushort.MaxValue + + + + + Send data to peer + + Data + Number of channel (from 0 to channelsCount - 1) + Send options (reliable, unreliable, etc.) + + If size exceeds maximum limit: + MTU - headerSize bytes for Unreliable + Fragment count exceeded ushort.MaxValue + + + + + Send data to peer + + DataWriter with data + Number of channel (from 0 to channelsCount - 1) + Send options (reliable, unreliable, etc.) + + If size exceeds maximum limit: + MTU - headerSize bytes for Unreliable + Fragment count exceeded ushort.MaxValue + + + + + Send data to peer + + Data + Start of data + Length of data + Number of channel (from 0 to channelsCount - 1) + Delivery method (reliable, unreliable, etc.) + + If size exceeds maximum limit: + MTU - headerSize bytes for Unreliable + Fragment count exceeded ushort.MaxValue + + + + + Address type that you want to receive from NetUtils.GetLocalIp method + + + + + Some specific network utilities + + + + + Get all local ip addresses + + type of address (IPv4, IPv6 or both) + List with all local ip addresses + + + + Get all local ip addresses (non alloc version) + + result list + type of address (IPv4, IPv6 or both) + + + + Get first detected local ip address + + type of address (IPv4, IPv6 or both) + IP address if available. Else - string.Empty + + + + Compute CRC32C for data + + input data + offset + length + CRC32C checksum + + + + Creates NetDataWriter from existing ByteArray + + Source byte array + Copy array to new location or use existing + + + + Creates NetDataWriter from existing ByteArray (always copied data) + + Source byte array + Offset of array + Length of array + + + + Sets position of NetDataWriter to rewrite previous values + + new byte position + previous position of data writer + + + + Register nested property type + + INetSerializable structure + + + + Register nested property type + + + + + + + Register nested property type + + INetSerializable class + + + + Reads all available data from NetDataReader and calls OnReceive delegates + + NetDataReader with packets data + + + + Reads all available data from NetDataReader and calls OnReceive delegates + + NetDataReader with packets data + Argument that passed to OnReceivedEvent + Malformed packet + + + + Reads one packet from NetDataReader and calls OnReceive delegate + + NetDataReader with packet + Malformed packet + + + + Reads one packet from NetDataReader and calls OnReceive delegate + + NetDataReader with packet + Argument that passed to OnReceivedEvent + Malformed packet + + + + Register and subscribe to packet receive event + + event that will be called when packet deserialized with ReadPacket method + Method that constructs packet instead of slow Activator.CreateInstance + 's fields are not supported, or it has no fields + + + + Register and subscribe to packet receive event (with userData) + + event that will be called when packet deserialized with ReadPacket method + Method that constructs packet instead of slow Activator.CreateInstance + 's fields are not supported, or it has no fields + + + + Register and subscribe to packet receive event + This method will overwrite last received packet class on receive (less garbage) + + event that will be called when packet deserialized with ReadPacket method + 's fields are not supported, or it has no fields + + + + Register and subscribe to packet receive event + This method will overwrite last received packet class on receive (less garbage) + + event that will be called when packet deserialized with ReadPacket method + 's fields are not supported, or it has no fields + + + + Remove any subscriptions by type + + Packet type + true if remove is success + + + + Register custom property type + + INetSerializable structure + + + + Register custom property type + + INetSerializable class + + + + Register custom property type + + Any packet + custom type writer + custom type reader + + + 's fields are not supported, or it has no fields + + + + Reads packet with known type + + NetDataReader with packet + Returns packet if packet in reader is matched type + 's fields are not supported, or it has no fields + + + + Reads packet with known type (non alloc variant) + + NetDataReader with packet + Deserialization target + Returns true if packet in reader is matched type + 's fields are not supported, or it has no fields + + + + Serialize object to NetDataWriter (fast) + + Serialization target NetDataWriter + Object to serialize + 's fields are not supported, or it has no fields + + + + Serialize object to byte array + + Object to serialize + byte array with serialized data + + + + Represents RFC4330 SNTP packet used for communication to and from a network time server. + + + + Most applications should just use the property. + + + The same data structure represents both request and reply packets. + Request and reply differ in which properties are set and to what values. + + + The only real property is . + All other properties read from and write to the underlying byte array + with the exception of , + which is not part of the packet on network and it is instead set locally after receiving the packet. + + + Copied from GuerrillaNtp project + with permission from Robert Vazan (@robertvazan) under MIT license, see https://github.com/RevenantX/LiteNetLib/pull/236 + + + + + + Gets RFC4330-encoded SNTP packet. + + + Byte array containing RFC4330-encoded SNTP packet. It is at least 48 bytes long. + + + This is the only real property. All other properties except + read from or write to this byte array. + + + + + Gets the leap second indicator. + + + Leap second warning, if any. Special value + indicates unsynchronized server clock. + Default is . + + + Only servers fill in this property. Clients can consult this property for possible leap second warning. + + + + + Gets or sets protocol version number. + + + SNTP protocol version. Default is 4, which is the latest version at the time of this writing. + + + In request packets, clients should leave this property at default value 4. + Servers usually reply with the same protocol version. + + + + + Gets or sets SNTP packet mode, i.e. whether this is client or server packet. + + + SNTP packet mode. Default is in newly created packets. + Server reply should have this property set to . + + + + + Gets server's distance from the reference clock. + + + + Distance from the reference clock. This property is set only in server reply packets. + Servers connected directly to reference clock hardware set this property to 1. + Statum number is incremented by 1 on every hop down the NTP server hierarchy. + + + Special value 0 indicates that this packet is a Kiss-o'-Death message + with kiss code stored in . + + + + + + Gets server's preferred polling interval. + + + Polling interval in log2 seconds, e.g. 4 stands for 16s and 17 means 131,072s. + + + + + Gets the precision of server clock. + + + Clock precision in log2 seconds, e.g. -20 for microsecond precision. + + + + + Gets the total round-trip delay from the server to the reference clock. + + + Round-trip delay to the reference clock. Normally a positive value smaller than one second. + + + + + Gets the estimated error in time reported by the server. + + + Estimated error in time reported by the server. Normally a positive value smaller than one second. + + + + + Gets the ID of the time source used by the server or Kiss-o'-Death code sent by the server. + + + + ID of server's time source or Kiss-o'-Death code. + Purpose of this property depends on value of property. + + + Stratum 1 servers write here one of several special values that describe the kind of hardware clock they use. + + + Stratum 2 and lower servers set this property to IPv4 address of their upstream server. + If upstream server has IPv6 address, the address is hashed, because it doesn't fit in this property. + + + When server sets to special value 0, + this property contains so called kiss code that instructs the client to stop querying the server. + + + + + + Gets or sets the time when the server clock was last set or corrected. + + + Time when the server clock was last set or corrected or null when not specified. + + + This Property is usually set only by servers. It usually lags server's current time by several minutes, + so don't use this property for time synchronization. + + + + + Gets or sets the time when the client sent its request. + + + This property is null in request packets. + In reply packets, it is the time when the client sent its request. + Servers copy this value from + that they find in received request packet. + + + + + + + Gets or sets the time when the request was received by the server. + + + This property is null in request packets. + In reply packets, it is the time when the server received client request. + + + + + + + Gets or sets the time when the packet was sent. + + + Time when the packet was sent. It should never be null. + Default value is . + + + This property must be set by both clients and servers. + + + + + + + Gets or sets the time of reception of response SNTP packet on the client. + + + Time of reception of response SNTP packet on the client. It is null in request packets. + + + This property is not part of the protocol and has to be set when reply packet is received. + + + + + + + Gets the round-trip time to the server. + + + Time the request spent traveling to the server plus the time the reply spent traveling back. + This is calculated from timestamps in the packet as (t1 - t0) + (t3 - t2) + where t0 is , + t1 is , + t2 is , + and t3 is . + This property throws an exception in request packets. + + + + + Gets the offset that should be added to local time to synchronize it with server time. + + + Time difference between server and client. It should be added to local time to get server time. + It is calculated from timestamps in the packet as 0.5 * ((t1 - t0) - (t3 - t2)) + where t0 is , + t1 is , + t2 is , + and t3 is . + This property throws an exception in request packets. + + + + + Initializes default request packet. + + + Properties and + are set appropriately for request packet. Property + is set to . + + + + + Initializes packet from received data. + + + + + Initializes packet from data received from a server. + + Data received from the server. + Utc time of reception of response SNTP packet on the client. + + + + + Represents leap second warning from the server that instructs the client to add or remove leap second. + + + + + + No leap second warning. No action required. + + + + + Warns the client that the last minute of the current day has 61 seconds. + + + + + Warns the client that the last minute of the current day has 59 seconds. + + + + + Special value indicating that the server clock is unsynchronized and the returned time is unreliable. + + + + + Describes SNTP packet mode, i.e. client or server. + + + + + + Identifies client-to-server SNTP packet. + + + + + Identifies server-to-client SNTP packet. + + + +