Class UdpClient
Netly, Udp client implementation
Assembly: Netly.dll
View Source
public class UdpClient
Properties
IsOpened
Return true when connection is opened
View Source
public bool IsOpened { get; }
Host
Host container
View Source
public Host Host { get; }
UseConnection
Return true when connection is enabled (using ping)
View Source
public bool UseConnection { get; }
Timeout
Return timeout value, is milliseconds
View Source
public int Timeout { get; }
Fields
UUID
Unique User Identifier, only server-side client
View Source
public readonly string UUID
Methods
Open(Host)
Open udp connection
View Source
public void Open(Host host)
Parameters
Type | Name | Description |
---|---|---|
Netly.Core.Host | host | Endpoint container |
Close()
Close udp connection
View Source
public void Close()
ToData(byte[])
Send raw buffer
View Source
public void ToData(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | buffer |
ToData(string)
Send raw buffer
View Source
public void ToData(string buffer)
Parameters
Type | Name | Description |
---|---|---|
System.String | buffer | buffer |
ToEvent(string, byte[])
Send event (netly-event)
You can create event using:
Netly.Core.EventManager.Create(string name, byte[] data);
And you can verify is a buffer is event (netly-event) using:
// When name or data is null, it mean isn't event (netly-event)
(string name, byte[] data) = Netly.Core.EventManager.Verify(byte[] data);
View Source
public void ToEvent(string name, byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | name of event |
System.Byte[] | buffer | buffer of event |
ToEvent(string, string)
Send event (netly-event)
You can create event using:
Netly.Core.EventManager.Create(string name, byte[] data);
And you can verify is a buffer is event (netly-event) using:
// When name or data is null, it mean isn't event (netly-event)
(string name, byte[] data) = Netly.Core.EventManager.Verify(byte[] data);
View Source
public void ToEvent(string name, string buffer)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | name of event |
System.String | buffer | buffer of event |
OnOpen(Action)
Callback will called when is connection opened
View Source
public void OnOpen(Action callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action | callback | callback |
OnError(Action<Exception>)
Callback will called when connection isn't opened
View Source
public void OnError(Action<Exception> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.Exception> | callback | callback |
OnClose(Action)
Callback will called when connection is closed
View Source
public void OnClose(Action callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action | callback | callback |
OnData(Action<byte[]>)
Callback will called when receive raw data
View Source
public void OnData(Action<byte[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.Byte[]> | callback | callback |
OnEvent(Action<string, byte[]>)
Callback will called when receive event (netly-event)
You can create event using:
Netly.Core.EventManager.Create(string name, byte[] data);
And you can verify is a buffer is event (netly-event) using:
// When name or data is null, it mean isn't event (netly-event)
(string name, byte[] data) = Netly.Core.EventManager.Verify(byte[] data);
View Source
public void OnEvent(Action<string, byte[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.String,System.Byte[]> | callback | callback |
OnModify(Action<Socket>)
Callback will called after create Socket Instance, and before open connection
You can use the socket for modify default values
View Source
public void OnModify(Action<Socket> callback)
Parameters
Type | Name |
---|---|
System.Action<System.Net.Sockets.Socket> | callback |