Skip to content

Exomia.Network

Daniel Baetz edited this page Jul 26, 2019 · 28 revisions

ClientBase

A TCP/UDP-Client base.

public abstract class Exomia.Network.ClientBase
    : IClient, IDisposable

Constructors

.ctor ClientBase()

Summary:

Initializes a new instance of the Exomia.Network.ClientBase class.



Fields

Socket _clientSocket

Summary:

The client socket.


Byte _state

Summary:

The state.



Properties

Int32 Port

Summary:

Port.


String ServerAddress

Summary:

ServerAddress.



Events

DisconnectedHandler Disconnected

Summary:

called than the client is Disconnected.


Action Ping

Summary:

called than a ping is received.



Methods

void AddCommand(UInt32 commandid, DeserializePacketHandler deserialize)

Summary:

add a command.

Parameter:

  • commandid - command id.
  • deserialize - .

void AddDataReceivedCallback(UInt32 commandid, DataReceivedHandler callback)

Summary:

add a data received callback.

Parameter:

  • commandid - command id.
  • callback - callback.

SendError BeginSendData(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, UInt32 responseid)

Summary:

Begins send data.

Parameter:

  • commandid - command id.
  • data - The data.
  • offset - The offset.
  • length - The length.
  • responseid - Identifier for the response.

Boolean Connect(IPAddress[] ipAddresses, Int32 port, Int32 timeout = 10)

Summary:

try's to connect the client to a server.

Parameter:

  • ipAddresses - .
  • port - .
  • timeout - (Optional)

Boolean Connect(String serverAddress, Int32 port, Int32 timeout = 10)

Summary:

try's to connect the client to a server.

Parameter:

  • serverAddress - .
  • port - .
  • timeout - (Optional)

void DeserializeData(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, UInt32 responseid)

Summary:

Deserialize data.

Parameter:

  • commandid - command id.
  • data - The data.
  • offset - The offset.
  • length - The length.
  • responseid - The responseid.

void Disconnect()

Summary:

call to disconnect from a server.


void Disconnect(DisconnectReason reason)

Summary:

Disconnects the given reason.

Parameter:

  • reason - The reason to disconnect.

    void Dispose()
void OnDispose(Boolean disposing)

Summary:

OnDispose.

Parameter:

  • disposing - disposing.

void ReceiveAsync()

Summary:

Receive asynchronous.


void RemoveCommand(UInt32 commandid)

Summary:

remove a command.

Parameter:

  • commandid - command id.

void RemoveDataReceivedCallback(UInt32 commandid, DataReceivedHandler callback)

Summary:

remove a data received callback.

Parameter:

  • commandid - command id.
  • callback - DataReceivedHandler.

SendError Send(UInt32 commandid, Byte[] data, Int32 offset, Int32 length)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.

SendError Send(UInt32 commandid, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.

SendError Send(UInt32 commandid, T& data)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.

SendError SendPing()

Summary:

send a ping command to the server.


Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.

Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, DeserializePacketHandler deserialize)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - .

Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.
  • timeout - timeout.

Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, DeserializePacketHandler deserialize, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - .
  • timeout - timeout.

Task> SendR(UInt32 commandid, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.

Task> SendR(UInt32 commandid, ISerializable serializable, DeserializePacketHandler deserialize)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.
  • deserialize - .

Task> SendR(UInt32 commandid, ISerializable serializable, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.
  • timeout - timeout.

Task> SendR(UInt32 commandid, ISerializable serializable, DeserializePacketHandler deserialize, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.
  • deserialize - .
  • timeout - timeout.

Task> SendR(UInt32 commandid, T& data)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.

Task> SendR(UInt32 commandid, T& data, DeserializePacketHandler deserialize)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.
  • deserialize - .

Task> SendR(UInt32 commandid, T& data, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.
  • timeout - timeout.

Task> SendR(UInt32 commandid, T& data, DeserializePacketHandler deserialize, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.
  • deserialize - .
  • timeout - timeout.

Task> SendRPing()

Summary:

send a ping command to the server.


Boolean TryCreateSocket(Socket& socket)

Summary:

Attempts to create socket.

Parameter:

  • socket - [out] The socket.


Static Fields

Byte RECEIVE_FLAG

Summary:

The receive flag.


Byte SEND_FLAG

Summary:

The send flag.



CommandID

CommandID.

public static class Exomia.Network.CommandID

Static Fields

UInt32 CONNECT

Summary:

CONNECT_ID.


UInt32 DISCONNECT

Summary:

DISCONNECT_ID.


UInt32 PING

Summary:

PING_ID.



CompressionMode

Values that represent CompressionMode. MASK 0b00111000.

public enum Exomia.Network.CompressionMode
    : Enum, IComparable, IFormattable, IConvertible

Enum

0 None

Summary:

None


32 Lz4

Summary:

LZ4



DisconnectReason

Values that represent DisconnectReason.

public enum Exomia.Network.DisconnectReason
    : Enum, IComparable, IFormattable, IConvertible

Enum

0 Unspecified

Summary:

Unspecified/Unknown Reason


1 Graceful

Summary:

Graceful


2 Aborted

Summary:

Aborted


3 Error

Summary:

Error



EncryptionMode

Values that represent EncryptionMode. MASK 0b00000111.

public enum Exomia.Network.EncryptionMode
    : Enum, IComparable, IFormattable, IConvertible

Enum

0 None

Summary:

None


4 End2End

Summary:

End2End



IClient

IClient interface.

public interface Exomia.Network.IClient
    : IDisposable

Methods

Boolean Connect(String serverAddress, Int32 port, Int32 timeout = 10)

Summary:

try's to connect the client to a server.

Parameter:

  • serverAddress - .
  • port - .
  • timeout - (Optional)

Boolean Connect(IPAddress[] ipAddresses, Int32 port, Int32 timeout = 10)

Summary:

try's to connect the client to a server.

Parameter:

  • ipAddresses - .
  • port - .
  • timeout - (Optional)

void Disconnect()

Summary:

call to disconnect from a server.


SendError Send(UInt32 commandid, Byte[] data, Int32 offset, Int32 length)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.

SendError Send(UInt32 commandid, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.

SendError Send(UInt32 commandid, T& data)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.

SendError SendPing()

Summary:

send a ping command to the server.


Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.

Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, DeserializePacketHandler deserialize)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - .

Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.
  • timeout - timeout.

Task> SendR(UInt32 commandid, Byte[] data, Int32 offset, Int32 length, DeserializePacketHandler deserialize, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - .
  • timeout - timeout.

Task> SendR(UInt32 commandid, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.

Task> SendR(UInt32 commandid, ISerializable serializable, DeserializePacketHandler deserialize)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.
  • deserialize - .

Task> SendR(UInt32 commandid, ISerializable serializable, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.
  • timeout - timeout.

Task> SendR(UInt32 commandid, ISerializable serializable, DeserializePacketHandler deserialize, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • serializable - ISerializable.
  • deserialize - .
  • timeout - timeout.

Task> SendR(UInt32 commandid, T& data)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.

Task> SendR(UInt32 commandid, T& data, DeserializePacketHandler deserialize)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.
  • deserialize - .

Task> SendR(UInt32 commandid, T& data, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.
  • timeout - timeout.

Task> SendR(UInt32 commandid, T& data, DeserializePacketHandler deserialize, TimeSpan timeout)

Summary:

send data to the server.

Parameter:

  • commandid - command id.
  • data - struct data.
  • deserialize - .
  • timeout - timeout.

Task> SendRPing()

Summary:

send a ping command to the server.



Packet

Packet readonly struct.

public struct Exomia.Network.Packet

Constructors

.ctor Packet(Byte[] buffer, Int32 offset, Int32 length)

Summary:

Initializes a new instance of the Exomia.Network.Packet struct.

Parameter:

  • buffer - The buffer.
  • offset - The offset.
  • length - The length.


Fields

Byte[] Buffer

Summary:

The buffer.


Int32 Length

Summary:

The length.


Int32 Offset

Summary:

The offset.



Response

A response.

public struct Exomia.Network.Response<TResult>

Constructors

.ctor Response`1(TResult& result, SendError sendError)

Summary:

Initializes a new instance of the Exomia.Network.Response`1 struct.

Parameter:

  • result - The result.
  • sendError - The send error.


Fields

TResult Result

Summary:

The result.


SendError SendError

Summary:

The send error.



SendError

Values that represent SendError.

public enum Exomia.Network.SendError
    : Enum, IComparable, IFormattable, IConvertible

Enum

0 None

Summary:

No error, all good


1 Socket

Summary:

A socket exception is occured


2 Disposed

Summary:

The socket was disposed


3 Invalid

Summary:

The SEND_FLAG is not set


4 Unknown

Summary:

Unknown error occured



ServerBase<T, TServerClient>

A server base.

public abstract class Exomia.Network.ServerBase<T, TServerClient>
    : IServer<T, TServerClient>, IDisposable

Constructors

.ctor ServerBase`2()

Summary:

ServerBase constructor.



Fields

Dictionary _clients

Summary:

Dictionary{T, TServerClient}


Socket _listener

Summary:

The listener.


Int32 _port

Summary:

The port.


Byte _state

Summary:

The state.



Properties

Int32 Port

Summary:

Port.



Events

ClientActionHandler ClientConnected

Summary:

called than a client is connected.


ClientDisconnectHandler ClientDisconnected

Summary:

called than a client is disconnected.



Methods

void AddCommand(UInt32 commandid, DeserializePacketHandler deserialize)

Summary:

add a command.

Parameter:

  • commandid - command id.
  • deserialize - .

void AddDataReceivedCallback(UInt32 commandid, ClientDataReceivedHandler callback)

Summary:

add a data received callback.

Parameter:

  • commandid - command id.
  • callback - ClientDataReceivedHandler{Socket|Endpoint}

Boolean CreateServerClient(T arg0, TServerClient& serverClient)

Summary:

Create a new ServerClient than a client connects.

Parameter:

  • arg0 - Socket|EndPoint.
  • serverClient - [out] out new ServerClient.

void DeserializeData(T arg0, UInt32 commandid, Byte[] data, Int32 offset, Int32 length, UInt32 responseid)

Summary:

Deserialize data.

Parameter:

  • arg0 - Socket|Endpoint.
  • commandid - command id.
  • data - The data.
  • offset - The offset.
  • length - The length.
  • responseid - The responseid.

    void Dispose()
void InvokeClientDisconnect(T arg0, DisconnectReason reason)

Summary:

Executes the client disconnect on a different thread, and waits for the result.

Parameter:

  • arg0 - Socket|Endpoint.
  • reason - DisconnectReason.

void ListenAsync()

Summary:

Listen asynchronous.


void OnAfterClientDisconnect(T arg0)

Summary:

called after Exomia.Network.ServerBase`2.InvokeClientDisconnect(`0,Exomia.Network.DisconnectReason).

Parameter:

  • arg0 - Socket|EndPoint.

void OnClientConnected(T arg0)

Summary:

called than a new client is connected.

Parameter:

  • arg0 - Socket|Endpoint.

void OnClientDisconnected(T arg0, DisconnectReason reason)

Summary:

called then the client is connected.

Parameter:

  • arg0 - Socket|EndPoint.
  • reason - DisconnectReason.

void OnDispose(Boolean disposing)

Summary:

OnDispose.

Parameter:

  • disposing - disposing.

Boolean OnRun(Int32 port, Socket& listener)

Summary:

Executes the run action.

Parameter:

  • port - Port.
  • listener - [out] The listener.

Boolean RemoveCommand(UInt32 commandid)

Summary:

remove a command.

Parameter:

  • commandid - command id.

void RemoveDataReceivedCallback(UInt32 commandid, ClientDataReceivedHandler callback)

Summary:

remove a data received callback.

Parameter:

  • commandid - command id.
  • callback - ClientDataReceivedHandler{Socket|Endpoint}

    Boolean Run(Int32 port)
    SendError SendTo(T arg0, UInt32 commandid, Byte[] data, Int32 offset, Int32 length, UInt32 responseid)
    SendError SendTo(TServerClient client, UInt32 commandid, Byte[] data, Int32 offset, Int32 length, UInt32 responseid)
    SendError SendTo(TServerClient client, UInt32 commandid, ISerializable serializable, UInt32 responseid)
    SendError SendTo(TServerClient client, UInt32 commandid, T1& data, UInt32 responseid)
    void SendToAll(UInt32 commandid, Byte[] data, Int32 offset, Int32 length)
    void SendToAll(UInt32 commandid, T1& data)
    void SendToAll(UInt32 commandid, ISerializable serializable)

Static Fields

Int32 CLOSE_TIMEOUT

Summary:

The close timeout.


Byte RECEIVE_FLAG

Summary:

The receive flag.


Byte SEND_FLAG

Summary:

The send flag.



ServerClientBase

A server client base.

public abstract class Exomia.Network.ServerClientBase<T>

Constructors

.ctor ServerClientBase`1(T arg0)

Summary:

ServerClientBase constructor.

Parameter:

  • arg0 - Socket|Endpoint.


Fields

T _arg0

Summary:

Socket|Endpoint.



Properties

    T Arg0
EndPoint EndPoint

Summary:

EndPoint.


IPAddress IPAddress

Summary:

IPAddress.


DateTime LastReceivedPacketTimeStamp

Summary:

LastReceivedPacketTimeStamp.



Methods

void SetLastReceivedPacketTimeStamp()

Summary:

Sets last received packet time stamp.