Interface IUnconnectedUdpPeer
Interface for unconnected UPD peers. Contains UPD Peer Api for unconnected messages only.
Namespace: Eco.Shared.Networking.Udp
Assembly: Eco.Shared.dll
Syntax
public interface IUnconnectedUdpPeer
Properties
IsRunning
Gets running state of the peer.
Declaration
bool IsRunning { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LocalEndPoint
Local IP End Point for the peer.
Declaration
IPEndPoint LocalEndPoint { get; }
Property Value
Type | Description |
---|---|
System.Net.IPEndPoint |
MaximumUnconnectedMessageLength
MTU - maximum transmission unit size. Maximum size of UPD packet.
Declaration
int MaximumUnconnectedMessageLength { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Port
Gets local port.
Declaration
int Port { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
add_UnconnectedDataMessageReceived(UdpDataMessageHandler)
Declaration
void add_UnconnectedDataMessageReceived(UdpDataMessageHandler value)
Parameters
Type | Name | Description |
---|---|---|
UdpDataMessageHandler | value |
remove_UnconnectedDataMessageReceived(UdpDataMessageHandler)
Declaration
void remove_UnconnectedDataMessageReceived(UdpDataMessageHandler value)
Parameters
Type | Name | Description |
---|---|---|
UdpDataMessageHandler | value |
SendRaw(IPEndPoint, Byte[], Int32, Int32)
Sends raw data with socket to destination peer.
It releases buffer after a send operation, so it is safe to reuse the messageData
buffer.
Declaration
void SendRaw(IPEndPoint remoteEndPoint, byte[] messageData, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Net.IPEndPoint | remoteEndPoint | destination end point. |
System.Byte[] | messageData | message data to send. |
System.Int32 | offset | offset in message data. |
System.Int32 | length | length of message. |
SendUnconnectedMessage(IPEndPoint, Byte[], Int32, Int32)
Sends unconnected message with network lib to destination peer.
It releases buffer after a send operation, so it is safe to reuse the messageData
buffer.
Declaration
void SendUnconnectedMessage(IPEndPoint remoteEndPoint, byte[] messageData, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Net.IPEndPoint | remoteEndPoint | destination end point. |
System.Byte[] | messageData | message data to send. |
System.Int32 | offset | offset in message data. |
System.Int32 | length | length of message. |
Service(Int32)
Services network messages - sending, receiving, connecting etc. You should call this method regular. /// Typical usage is following:
while (peer.IsRunning)
peer.Service(10);
You can service single network event with ServiceOne(Int32).
Declaration
void Service(int timeoutMs)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutMs | Maximum timeout between events. It will return if timeout exceed. |
ServiceOne(Int32)
Same as Service(Int32), but only service single network event.
Declaration
bool ServiceOne(int timeoutMs)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutMs | Maximum timeout until event. It will return |
Returns
Type | Description |
---|---|
System.Boolean |
|
Shutdown()
Shutdowns peers. Releases resources and stops background threads (if any).
Declaration
void Shutdown()
Start()
Starts peer. Makes initialization, creates socket and optionally starts background message processing thread. You need to call Service(Int32) or ServiceOne(Int32) to have network messages processed and trigger message events.
Declaration
void Start()
SyncTimer(Double)
Synchronize timers. Ensures local timer and network timer will use same time base.
Declaration
void SyncTimer(double currentTimeInSeconds)
Parameters
Type | Name | Description |
---|---|---|
System.Double | currentTimeInSeconds | current time on your timer. |
Events
DebugMessageReceived
Event called when a debug message received.
Declaration
event Action<string> DebugMessageReceived
Event Type
Type | Description |
---|---|
System.Action<System.String> |
ErrorMessageReceived
Event called when an error message received.
Declaration
event Action<string> ErrorMessageReceived
Event Type
Type | Description |
---|---|
System.Action<System.String> |
UnconnectedDataMessageReceived
Event called when unconnected data message received.
Declaration
event UdpDataMessageHandler UnconnectedDataMessageReceived
Event Type
Type | Description |
---|---|
UdpDataMessageHandler |
WarningMessageReceived
Event called when a warning message received.
Declaration
event Action<string> WarningMessageReceived
Event Type
Type | Description |
---|---|
System.Action<System.String> |