NetworkClient
Namespace: TagBites.Net
Assembly: TagBites.Net.dll
TCP client which allows to send objects messages and execute remote methods. This class is thread safe.
public abstract class NetworkClient : System.IDisposable
Constructors
NetworkClient()
protected void NetworkClient()
Result Type: void
Properties
IsConnected
Gets a value indicating whether connection is active.
public bool IsConnected { get; }
Result Type: bool
IsDisposed
Gets a value indicating whether object already disposed or not.
public bool IsDisposed { get; }
Result Type: bool
Methods
Close()
Closes the connection.
public void Close()
Result Type: void
Dispose()
public void Dispose()
Result Type: void
Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
protected void Dispose(bool disposing)
Result Type: void
Parameters
Type | Name | |
---|---|---|
bool | disposing |
GetController<T>()
Returns the remote controller.
public T GetController()
Result Type: T
OnConnectionClosed(object, NetworkConnectionClosedEventArgs)
Invokes TagBites.Net.NetworkClient.Disconnected event.
protected void OnConnectionClosed(object sender, NetworkConnectionClosedEventArgs e)
Result Type: void
Parameters
Type | Name | |
---|---|---|
object | sender | |
NetworkConnectionClosedEventArgs | e |
OnControllerResolve(object, NetworkConnectionControllerResolveEventArgs)
Invokes TagBites.Net.NetworkClient.ControllerResolve event.
protected void OnControllerResolve(object sender, NetworkConnectionControllerResolveEventArgs e)
Result Type: void
Parameters
Type | Name | |
---|---|---|
object | sender | |
NetworkConnectionControllerResolveEventArgs | e |
OnReceived(object, NetworkConnectionMessageEventArgs)
Invokes TagBites.Net.NetworkClient.Received event.
protected void OnReceived(object sender, NetworkConnectionMessageEventArgs e)
Result Type: void
Parameters
Type | Name | |
---|---|---|
object | sender | |
NetworkConnectionMessageEventArgs | e |
OnReceivedError(object, NetworkConnectionMessageErrorEventArgs)
Invokes TagBites.Net.NetworkClient.ReceivedError event.
protected void OnReceivedError(object sender, NetworkConnectionMessageErrorEventArgs e)
Result Type: void
Parameters
Type | Name | |
---|---|---|
object | sender | |
NetworkConnectionMessageErrorEventArgs | e |
SendAsync(object)
public Task SendAsync(object message)
Result Type: Task
Parameters
Type | Name | |
---|---|---|
object | message |
Events
ControllerResolve
Occurs when server requests access to controller for the first time. It allows to create and return controller instance without register it first.
public EventHandler<NetworkConnectionControllerResolveEventArgs> ControllerResolve
Result Type: EventHandler<NetworkConnectionControllerResolveEventArgs>
Disconnected
Occurs when client disconnects form the server.
public EventHandler<NetworkConnectionClosedEventArgs> Disconnected
Result Type: EventHandler<NetworkConnectionClosedEventArgs>
Received
Occurs when server sends a message.
public EventHandler<NetworkConnectionMessageEventArgs> Received
Result Type: EventHandler<NetworkConnectionMessageEventArgs>
ReceivedError
Occurs when client was unable to receive server message (eg. deserialization error).
public EventHandler<NetworkConnectionMessageErrorEventArgs> ReceivedError
Result Type: EventHandler<NetworkConnectionMessageErrorEventArgs>