Class UdpPeerExtensions
Inheritance
Namespace: Eco.Shared.Networking
Assembly: Eco.Shared.dll
Syntax
public static class UdpPeerExtensions : Object
Methods
SendUnconnectedMessage(IUnconnectedUdpPeer, IPEndPoint, MemoryStream)
Declaration
public static void SendUnconnectedMessage(this IUnconnectedUdpPeer udpPeer, IPEndPoint remoteEndPoint, MemoryStream stream)
Parameters
Type | Name | Description |
---|---|---|
IUnconnectedUdpPeer | udpPeer | |
System.Net.IPEndPoint | remoteEndPoint | |
System.IO.MemoryStream | stream |
SendUnconnectedMessage(IUnconnectedUdpPeer, IPEndPoint, MemoryStream, Boolean)
Declaration
public static void SendUnconnectedMessage(this IUnconnectedUdpPeer peer, IPEndPoint recipient, MemoryStream message, bool withFragmentation)
Parameters
Type | Name | Description |
---|---|---|
IUnconnectedUdpPeer | peer | |
System.Net.IPEndPoint | recipient | |
System.IO.MemoryStream | message | |
System.Boolean | withFragmentation |
SendUnconnectedMessageWithFragmentation(IUnconnectedUdpPeer, IPEndPoint, MemoryStream)
Sends unconnected message to recipient with fragmentation support. Fragmented messages conforms to following protocol: [NetMessage.FragmentedMessage][fragmentation info byte][fragmented message guid][message body fragment]
[fragmentation info byte] - contains pair partIndex/numOfParts (4 bits each), lower 4 bits is a part index and upper 4 bits is a number of parts. If 0 then message is not fragmented [fragmented message guid] - Used as fragmented message identifier to assembly message from parts at destination. 16 bytes. [message body fragment] - actual message body. Each fragment will contain part of message body.
Samples: 0Hello World
One fragment: [\0][H][e][l][l][o][ ][W][o][r][l][d] Two fragments: [\10][\32][Guid:16 bytes][\0][H][e][l][l][o] [\10][\33][Guid:16 bytes][ ][W][o][r][l][d]
Following this protocol maximum useful allowed message length is: (MTU - 18) * 15.
Declaration
public static void SendUnconnectedMessageWithFragmentation(this IUnconnectedUdpPeer peer, IPEndPoint recipient, MemoryStream message)
Parameters
Type | Name | Description |
---|---|---|
IUnconnectedUdpPeer | peer | peer. |
System.Net.IPEndPoint | recipient | recipient endpoint. |
System.IO.MemoryStream | message | Message to send, if it matches MTU then it will be send as is, otherwise wrapped in fragmented message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if message body is too long to split into 15 fragments (max number of fragments). |