Skip to content

Exomia.Network

Daniel Baetz edited this page Aug 3, 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

BigDataHandler _bigDataHandler

Summary:

The big data handler.


Socket _clientSocket

Summary:

The client socket.


CompressionMode _compressionMode

Summary:

The compression mode.


EncryptionMode _encryptionMode

Summary:

The encryption mode.


Byte _state

Summary:

The state.



Properties

UInt16 MaxPayloadSize

Summary:

Gets the maximum size of the payload.


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(DeserializePacketHandler deserialize, UInt32[] commandIDs)

Summary:

add commands deserializers.

Parameter:

  • deserialize - The deserialize handler.
  • commandIDs - A variable-length parameters list containing command ids.

void AddDataReceivedCallback(UInt32 commandID, DataReceivedHandler callback)

Summary:

add a data received callback.

Parameter:

  • commandID - Identifier for the command.
  • callback - The callback.

SendError BeginSendData(PacketInfo& packetInfo)

Summary:

Begins send data.

Parameter:

  • packetInfo - Information describing the packet.

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.


Boolean RemoveCommands(UInt32[] commandIDs)

Summary:

Removes the commands described by commandIDs.

Parameter:

  • commandIDs - A variable-length parameters list containing command ids.

void RemoveDataReceivedCallback(UInt32 commandID, DataReceivedHandler callback)

Summary:

remove a data received callback.

Parameter:

  • commandID - Identifier for the command.
  • callback - The callback.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - data.
  • offset - offset.
  • length - length of data.

SendError Send(UInt32 commandID, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.

SendError Send(UInt32 commandID, T& data)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • 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 - Identifier for the command.
  • 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 - Identifier for the command.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - The deserialize.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • 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 - Identifier for the command.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - The deserialize.
  • timeout - timeout.

Task> SendR(UInt32 commandID, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.
  • deserialize - The deserialize.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.
  • timeout - timeout.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.
  • deserialize - The deserialize.
  • timeout - timeout.

Task> SendR(UInt32 commandID, T& data)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.
  • deserialize - The deserialize.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.
  • timeout - timeout.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.
  • deserialize - The 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.



CompressionMode

Values that represent CompressionMode. MASK 0b00111000.

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

Enum

0 None

Summary:

None


8 Lz4

Summary:

LZ4


16 Unused1

Summary:

Unused1


24 Unused2

Summary:

Unused2


32 Unused3

Summary:

Unused3


40 Unused4

Summary:

Unused4


48 Unused5

Summary:

Unused5


56 Unused6

Summary:

Unused6



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 - Identifier for the command.
  • data - data.
  • offset - offset.
  • length - length of data.

SendError Send(UInt32 commandID, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.

SendError Send(UInt32 commandID, T& data)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • 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 - Identifier for the command.
  • 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 - Identifier for the command.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - The deserialize.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • 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 - Identifier for the command.
  • data - data.
  • offset - offset.
  • length - length of data.
  • deserialize - The deserialize.
  • timeout - timeout.

Task> SendR(UInt32 commandID, ISerializable serializable)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.
  • deserialize - The deserialize.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.
  • timeout - timeout.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • serializable - ISerializable.
  • deserialize - The deserialize.
  • timeout - timeout.

Task> SendR(UInt32 commandID, T& data)

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.
  • deserialize - The deserialize.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.
  • timeout - timeout.

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

Summary:

send data to the server.

Parameter:

  • commandID - Identifier for the command.
  • data - struct data.
  • deserialize - The deserialize.
  • timeout - timeout.

Task> SendRPing()

Summary:

send a ping command to the server.



IServer

Interface for server.

public interface Exomia.Network.IServer<TServerClient>
    : IDisposable

Methods

SendError SendTo(TServerClient client, UInt32 commandID, Byte[] data, Int32 offset, Int32 length, UInt32 responseID)

Summary:

Sends data to the client.

Parameter:

  • client - The client.
  • commandID - Identifier for the command.
  • data - The data.
  • offset - The offset.
  • length - The length.
  • responseID - Identifier for the response.

SendError SendTo(TServerClient client, UInt32 commandID, ISerializable serializable, UInt32 responseID)

Summary:

Sends data to the client.

Parameter:

  • client - The client.
  • commandID - Identifier for the command.
  • serializable - The serializable.
  • responseID - Identifier for the response.

SendError SendTo(TServerClient client, UInt32 commandID, T1& data, UInt32 responseID)

Summary:

Sends data to the client.

Parameter:

  • client - The client.
  • commandID - Identifier for the command.
  • data - The data.
  • responseID - Identifier for the response.

void SendToAll(UInt32 commandID, Byte[] data, Int32 offset, Int32 length)

Summary:

Sends data to all clients.

Parameter:

  • commandID - Identifier for the command.
  • data - The data.
  • offset - The offset.
  • length - The length.

void SendToAll(UInt32 commandID, ISerializable serializable)

Summary:

Sends data to all clients.

Parameter:

  • commandID - Identifier for the command.
  • serializable - The serializable.

void SendToAll(UInt32 commandID, T1& data)

Summary:

Sends data to all clients.

Parameter:

  • commandID - Identifier for the command.
  • data - The data.


IServerClient

Interface for server client.

public interface Exomia.Network.IServerClient

Properties

IPAddress IPAddress

Summary:

Gets the IP address.


DateTime LastReceivedPacketTimeStamp

Summary:

Gets the Date/Time of the last received packet time stamp.



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.



Methods

    String ToString()
String ToString(Encoding encoding)

Summary:

Convert this packets raw data into a string representation.

Parameter:

  • encoding - The encoding.


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<TServerClient>, IDisposable

Constructors

.ctor ServerBase`2()

Summary:

Initializes a new instance of the Exomia.Network.ServerBase`2 class.



Fields

BigDataHandler _bigDataHandler

Summary:

The big data handler.


Dictionary _clients

Summary:

The clients.


CompressionMode _compressionMode

Summary:

The compression mode.


EncryptionMode _encryptionMode

Summary:

The encryption mode.


Socket _listener

Summary:

The listener.


Int32 _port

Summary:

The port.


Byte _state

Summary:

The state.



Properties

UInt16 MaxPayloadSize

Summary:

Gets the maximum size of the payload.


Int32 Port

Summary:

Gets the port.



Events

ClientActionHandler ClientConnected

Summary:

Called than a client is connected.


ClientCommandDataReceivedHandler ClientDataReceived

Summary:

Occurs when data from a client is received.


ClientDisconnectHandler ClientDisconnected

Summary:

Called than a client is disconnected.



Methods

void AddCommand(DeserializePacketHandler deserialize, UInt32[] commandIDs)

Summary:

add commands deserializers.

Parameter:

  • deserialize - The deserialize handler.
  • commandIDs - A variable-length parameters list containing command ids.

void AddDataReceivedCallback(UInt32 commandID, ClientDataReceivedHandler callback)

Summary:

add a data received callback.

Parameter:

  • commandID - Identifier for the command.
  • callback - ClientDataReceivedHandler{Socket|Endpoint}

Boolean CreateServerClient(TServerClient& serverClient)

Summary:

Create a new ServerClient than a client connects.

Parameter:

  • 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 - Identifier for the command.
  • data - The data.
  • offset - The offset.
  • length - The length.
  • responseID - Identifier for the response.

    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 InvokeClientDisconnect(TServerClient client, DisconnectReason reason)

Summary:

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

Parameter:

  • client - The client.
  • reason - DisconnectReason.

void ListenAsync()

Summary:

Listen asynchronous.


void OnAfterClientDisconnect(TServerClient client)

Summary:

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

Parameter:

  • client - The client.

void OnClientConnected(TServerClient client)

Summary:

Called than a new client is connected.

Parameter:

  • client - The client.

void OnClientDisconnected(TServerClient client, DisconnectReason reason)

Summary:

Called then the client is disconnected.

Parameter:

  • client - The client.
  • 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 RemoveCommands(UInt32[] commandIDs)

Summary:

Removes the commands described by commandIDs.

Parameter:

  • commandIDs - A variable-length parameters list containing command ids.

void RemoveDataReceivedCallback(UInt32 commandID, ClientDataReceivedHandler callback)

Summary:

remove a data received callback.

Parameter:

  • commandID - Identifier for the command.
  • callback - ClientDataReceivedHandler{Socket|Endpoint}

Boolean Run(Int32 port)

Summary:

Runs.

Parameter:

  • port - Port.

SendError SendTo(T arg0, PacketInfo& packetInfo)

Summary:

Sends to.

Parameter:

  • arg0 - Socket|Endpoint.
  • packetInfo - Information describing the packet.

    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>
    : IServerClient

Constructors

.ctor ServerClientBase`1()

Summary:

Initializes a new instance of the Exomia.Network.ServerClientBase`1 class.



Fields

T _arg0

Summary:

Socket|Endpoint.



Properties

T Arg0

Summary:

Gets the argument 0.


IPAddress IPAddress

Summary:

Gets the IP address.


DateTime LastReceivedPacketTimeStamp

Summary:

Gets the Date/Time of the last received packet time stamp.



Methods

void SetLastReceivedPacketTimeStamp()

Summary:

Sets last received packet time stamp.