Show / Hide Table of Contents

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 false if the event won't happen.

Returns
Type Description
System.Boolean

true if the event serviced, false otherwise.

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>

Extension Methods

UdpPeerExtensions.SendUnconnectedMessage(IUnconnectedUdpPeer, IPEndPoint, MemoryStream, Boolean)
UdpPeerExtensions.SendUnconnectedMessageWithFragmentation(IUnconnectedUdpPeer, IPEndPoint, MemoryStream)
UdpPeerExtensions.SendUnconnectedMessage(IUnconnectedUdpPeer, IPEndPoint, MemoryStream)
NetMessage.SendDiscoveryRequest(IUnconnectedUdpPeer, IPEndPoint)
NetMessage.SendDiscoveryResponse(IUnconnectedUdpPeer, IPEndPoint, String)
NetMessage.SendPingRequest(IUnconnectedUdpPeer, IPEndPoint)
NetMessage.SendPingRequest(IUnconnectedUdpPeer, IPEndPoint, Double)
NetMessage.SendPingReply(IUnconnectedUdpPeer, IPEndPoint, Guid, Double)
CommandLine.FeedFromCommandLine(Object)
CommandLine.ToCommandLineArgs(Object, Func<Object, Boolean>)
ListUtil.DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
EnumerableExtensions.SingleItemAsEnumerable<T>(T)
EventUtils.RaiseEvent<TEventArgs>(Object, String, TEventArgs)
PredicateUtils.MatchesAll<TEnumerable, T>(T, TEnumerable)
PredicateUtils.MatchesAll<T>(T, Func<T, Boolean>[])
PredicateUtils.MatchesAny<TEnumerable, T>(T, TEnumerable)
ReflectionUtils.PropertyValue<T>(Object, PropertyInfo)
ReflectionUtils.TryGetPropertyValueByName<T>(Object, String, out T)
ReflectionUtils.GetPropertyValueByName<T>(Object, String)
ReflectionUtils.SetPropertyByName(Object, String, Object)
ReflectionUtils.GetStructPropertyByName<T>(Object, String)
ReflectionUtils.GetStringPropertyByName(Object, String)
ReflectionUtils.ZipByProperty<T>(Object, Object, Object, Func<T, T, T>)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾