Class ZOTCPServer
A TCP server.
Inheritance
Inherited Members
Namespace: ZO.Networking
Assembly: Unity.ZeroSim.dll
Syntax
public class ZOTCPServer
Properties
| Improve this Doc View SourceConnectedClientCount
Number of connected clients.
Declaration
public int ConnectedClientCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IPAddress
Declaration
public IPAddress IPAddress { get; set; }
Property Value
Type | Description |
---|---|
System.Net.IPAddress |
OnConnectedDelegate
Delegate for when a client is connected. Parameters: this, a TcpClient instance Return: Async Task
Declaration
public Func<ZOTCPServer, TcpClient, Task> OnConnectedDelegate { get; set; }
Property Value
Type | Description |
---|---|
System.Func<ZOTCPServer, System.Net.Sockets.TcpClient, System.Threading.Tasks.Task> |
OnConnectionClosedDelegate
Delegate for when a connection is closed. Parameters: this, the TcpClient that is disconnected. Returns: Async Task
Declaration
public Func<ZOTCPServer, TcpClient, Task> OnConnectionClosedDelegate { get; set; }
Property Value
Type | Description |
---|---|
System.Func<ZOTCPServer, System.Net.Sockets.TcpClient, System.Threading.Tasks.Task> |
OnDataReceivedDelegate
Delegate for when data is received. Parameters: this, MemoryStream containing data Returns: Async Task
Declaration
public Func<ZOTCPServer, MemoryStream, Task> OnDataReceivedDelegate { get; set; }
Property Value
Type | Description |
---|---|
System.Func<ZOTCPServer, System.IO.MemoryStream, System.Threading.Tasks.Task> |
Port
Declaration
public int Port { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceFinalize()
Declaration
protected void Finalize()
RunAsync()
Start listening asynchronously
Declaration
public Task RunAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAsync(ArraySegment<Byte>, TcpClient)
Send data asynchronously to specific client
Declaration
public Task SendAsync(ArraySegment<byte> data, TcpClient tcpClient)
Parameters
Type | Name | Description |
---|---|---|
System.ArraySegment<System.Byte> | data | byte array of data |
System.Net.Sockets.TcpClient | tcpClient | the tcp client to send data to. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAsync(MemoryStream, TcpClient)
Send data asynchronously to specific client using MemoryStream as a data container.
Declaration
public Task SendAsync(MemoryStream stream, TcpClient tcpClient)
Parameters
Type | Name | Description |
---|---|---|
System.IO.MemoryStream | stream | the data |
System.Net.Sockets.TcpClient | tcpClient | the connected client |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendToAllAsync(ArraySegment<Byte>)
Send data to all connected clients asynchronously.
Declaration
public Task SendToAllAsync(ArraySegment<byte> data)
Parameters
Type | Name | Description |
---|---|---|
System.ArraySegment<System.Byte> | data | The data array to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendToAllAsync(MemoryStream)
Send data asynchronously to all connnected clients using MemoryStream as a data container.
Declaration
public Task SendToAllAsync(MemoryStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.MemoryStream | stream | the data |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Stop()
Stops TcpServer and disconnects all clients.
Declaration
public void Stop()