-
-
Notifications
You must be signed in to change notification settings - Fork 3
Exomia.Network
A TCP/UDP-Client base.
public abstract class Exomia.Network.ClientBase
: IClient, IDisposable
.ctor
ClientBase(Byte
listenerCount = 1)
Initializes a new instance of the class.
-
listenerCount
- (Optional) The listener count.
void
AddCommand(DeserializePacketHandler
deserialize, UInt32[]
commandIDs)
add commands deserializers.
-
deserialize
- The deserialize handler. -
commandIDs
- A variable-length parameters list containing command ids.
void
AddDataReceivedCallback(UInt32
commandID, DataReceivedHandler
callback)
add a data received callback.
-
commandID
- Identifier for the command. -
callback
- The callback.
SendError
BeginSendData(PacketInfo&
packetInfo)
Begins send data.
-
packetInfo
- Information describing the packet.
Boolean
Connect(IPAddress[]
ipAddresses, Int32
port, Action
overwriteConfigure = null, Int32
timeout = 10)
try's to connect the client to a server.
-
ipAddresses
- The ip addresses. -
port
- The port. -
overwriteConfigure
- (Optional) Overwrite the default configuration. -
timeout
- (Optional) The timeout in seconds
Boolean
Connect(String
serverAddress, Int32
port, Action
overwriteConfigure = null, Int32
timeout = 10)
try's to connect the client to a server.
-
serverAddress
- The server address. -
port
- The port. -
overwriteConfigure
- (Optional) Overwrite the default configuration. -
timeout
- (Optional) The timeout in seconds
void
DeserializeData(DeserializePacketInfo&
deserializePacketInfo)
Deserialize data.
-
deserializePacketInfo
- Information describing the deserialize packet.
void
Disconnect(DisconnectReason
reason)
Disconnects the given reason.
-
reason
- The reason to disconnect.
void
Dispose()Boolean
RemoveCommands(UInt32[]
commandIDs)
Removes the commands described by commandIDs.
-
commandIDs
- A variable-length parameters list containing command ids.
void
RemoveDataReceivedCallback(UInt32
commandID, DataReceivedHandler
callback)
remove a data received callback.
-
commandID
- Identifier for the command. -
callback
- The callback.
SendError
Send(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data.
SendError
Send(UInt32
commandID, Byte[]
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
SendError
Send(UInt32
commandID, ISerializable
serializable)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable.
SendError
Send(UInt32
commandID, T&
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
Task>
SendR(UInt32
commandID, Byte[]
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, Byte[]
data, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, Byte[]
data, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, Byte[]
data, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data. -
deserialize
- The deserialize. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, ISerializable
serializable)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable.
Task>
SendR(UInt32
commandID, ISerializable
serializable, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, ISerializable
serializable, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, ISerializable
serializable, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable. -
deserialize
- The deserialize. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, T&
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
Task>
SendR(UInt32
commandID, T&
data, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, T&
data, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, T&
data, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize. -
timeout
- The timeout.
Boolean
TryCreateSocket(Socket&
socket)
Attempts to create socket.
-
socket
- [out] The socket.
Values that represent CompressionMode.
MASK 0b00111000.
public enum Exomia.Network.CompressionMode
: Enum, IComparable, IFormattable, IConvertible
Values that represent DisconnectReason.
public enum Exomia.Network.DisconnectReason
: Enum, IComparable, IFormattable, IConvertible
Values that represent EncryptionMode.
MASK 0b00000111.
public enum Exomia.Network.EncryptionMode
: Enum, IComparable, IFormattable, IConvertible
IClient interface.
public interface Exomia.Network.IClient
: IDisposable
Boolean
Connect(String
serverAddress, Int32
port, Action
overwriteConfigure = null, Int32
timeout = 10)
try's to connect the client to a server.
-
serverAddress
- The server address. -
port
- The port. -
overwriteConfigure
- (Optional) Overwrite the default configuration. -
timeout
- (Optional) The timeout in seconds
Boolean
Connect(IPAddress[]
ipAddresses, Int32
port, Action
overwriteConfigure = null, Int32
timeout = 10)
try's to connect the client to a server.
-
ipAddresses
- The ip addresses. -
port
- The port. -
overwriteConfigure
- (Optional) Overwrite the default configuration. -
timeout
- (Optional) The timeout in seconds
SendError
Send(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data.
SendError
Send(UInt32
commandID, Byte[]
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
SendError
Send(UInt32
commandID, ISerializable
serializable)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable.
SendError
Send(UInt32
commandID, T&
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data.
Task>
SendR(UInt32
commandID, Byte[]
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, Byte[]
data, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, Byte[]
data, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length of data. -
deserialize
- The deserialize. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, Byte[]
data, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, ISerializable
serializable)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable.
Task>
SendR(UInt32
commandID, ISerializable
serializable, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, ISerializable
serializable, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, ISerializable
serializable, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
serializable
- ISerializable. -
deserialize
- The deserialize. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, T&
data)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data.
Task>
SendR(UInt32
commandID, T&
data, DeserializePacketHandler
deserialize)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize.
Task>
SendR(UInt32
commandID, T&
data, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
timeout
- The timeout.
Task>
SendR(UInt32
commandID, T&
data, DeserializePacketHandler
deserialize, TimeSpan
timeout)
send data to the server.
-
commandID
- Identifier for the command. -
data
- The data. -
deserialize
- The deserialize. -
timeout
- The timeout.
Interface for server.
public interface Exomia.Network.IServer<TServerClient>
: IDisposable
SendError
SendTo(TServerClient
client, UInt32
commandID, Byte[]
data, Int32
offset, Int32
length, UInt32
responseID)
Sends data to the client.
-
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, Byte[]
data, UInt32
responseID)
Sends data to the client.
-
client
- The client. -
commandID
- Identifier for the command. -
data
- The data. -
responseID
- Identifier for the response.
SendError
SendTo(TServerClient
client, UInt32
commandID, ISerializable
serializable, UInt32
responseID)
Sends data to the client.
-
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)
Sends data to the client.
-
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)
Sends data to all clients.
-
commandID
- Identifier for the command. -
data
- The data. -
offset
- The offset. -
length
- The length.
void
SendToAll(UInt32
commandID, Byte[]
data)
Sends data to all clients.
-
commandID
- Identifier for the command. -
data
- The data.
void
SendToAll(UInt32
commandID, ISerializable
serializable)
Sends data to all clients.
-
commandID
- Identifier for the command. -
serializable
- The serializable.
void
SendToAll(UInt32
commandID, T1&
data)
Sends data to all clients.
-
commandID
- Identifier for the command. -
data
- The data.
Interface for server client.
public interface Exomia.Network.IServerClient
DateTime
LastReceivedPacketTimeStamp
Gets the Date/Time of the last received packet time stamp.
Packet readonly struct.
public struct Exomia.Network.Packet
.ctor
Packet(Byte[]
buffer, Int32
offset, Int32
length)
Initializes a new instance of the struct.
-
buffer
- The buffer. -
offset
- The offset. -
length
- The length.
String
ToString()String
ToString(Encoding
encoding)
Convert this packets raw data into a string representation.
-
encoding
- The encoding.
A response.
public struct Exomia.Network.Response<TResult>
.ctor
Response`1(TResult&
result, SendError
sendError)
Initializes a new instance of the struct.
-
result
- The result. -
sendError
- The send error.
Values that represent SendError.
public enum Exomia.Network.SendError
: Enum, IComparable, IFormattable, IConvertible
A server base.
public abstract class Exomia.Network.ServerBase<T, TServerClient>
: IServer<TServerClient>, IDisposable
.ctor
ServerBase`2(Byte
listenerCount = 1)
Initializes a new instance of the class.
-
listenerCount
- (Optional) The listener count.
ClientCommandDataReceivedHandler
ClientDataReceived
Occurs when data from a client is received.
void
AddCommand(DeserializePacketHandler
deserialize, UInt32[]
commandIDs)
add commands deserializers.
-
deserialize
- The deserialize handler. -
commandIDs
- A variable-length parameters list containing command ids.
void
AddDataReceivedCallback(UInt32
commandID, ClientDataReceivedHandler
callback)
add a data received callback.
-
commandID
- Identifier for the command. -
callback
- ClientDataReceivedHandler{Socket|Endpoint}
Boolean
CreateServerClient(TServerClient&
serverClient)
Create a new ServerClient than a client connects.
-
serverClient
- [out] out new ServerClient.
void
DeserializeData(T
arg0, DeserializePacketInfo&
deserializePacketInfo)
Deserialize data.
-
arg0
- Socket|Endpoint. -
deserializePacketInfo
- Information describing the deserialize packet.
void
Dispose()void
InvokeClientDisconnect(T
arg0, DisconnectReason
reason)
Executes the client disconnect on a different thread, and waits for the result.
-
arg0
- Socket|Endpoint. -
reason
- DisconnectReason.
void
InvokeClientDisconnect(TServerClient
client, DisconnectReason
reason)
Executes the client disconnect on a different thread, and waits for the result.
-
client
- The client. -
reason
- DisconnectReason.
void
OnAfterClientDisconnect(TServerClient
client)
called after .
-
client
- The client.
void
OnClientConnected(TServerClient
client)
Called than a new client is connected.
-
client
- The client.
void
OnClientDisconnected(TServerClient
client, DisconnectReason
reason)
Called then the client is disconnected.
-
client
- The client. -
reason
- DisconnectReason.
Boolean
OnRun(Int32
port, Socket&
listener)
Executes the run action.
-
port
- The port. -
listener
- [out] The listener.
Boolean
RemoveCommands(UInt32[]
commandIDs)
Removes the commands described by commandIDs.
-
commandIDs
- A variable-length parameters list containing command ids.
void
RemoveDataReceivedCallback(UInt32
commandID, ClientDataReceivedHandler
callback)
remove a data received callback.
-
commandID
- Identifier for the command. -
callback
- ClientDataReceivedHandler{Socket|Endpoint}
Boolean
Run(Int32
port, Action>
overwriteConfigure = null)
Runs.
-
port
- The port. -
overwriteConfigure
- (Optional) Overwrite the default configuration.
SendError
SendTo(T
arg0, PacketInfo&
packetInfo)
Sends to.
-
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, Byte[]
data, 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, Byte[]
data)void
SendToAll(UInt32
commandID, T1&
data)void
SendToAll(UInt32
commandID, ISerializable
serializable)A server client base.
public abstract class Exomia.Network.ServerClientBase<T>
: IServerClient
DateTime
LastReceivedPacketTimeStamp
Gets the Date/Time of the last received packet time stamp.