NetworkConnection

Namespace: TagBites.Net
Assembly: TagBites.Net.dll

public sealed class NetworkConnection : System.IDisposable

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

Listening

Gets or sets a value indicating whether is listening for commands/messages. Setting <c>true</c> starts background thread.

public bool Listening { get; set; }

Result Type: bool

Methods

Close()

Closes the connection. It waits for the end of the data transfer.

public void Close()

Result Type: void

Dispose()

Disposes the object without waiting for the end of the data transfer.

public void Dispose()

Result Type: void

GetController<T>()

Returns the remote controller.

public T GetController()

Result Type: T

ReadAsync()

Reads next object from socket. Thread waits until object is available.

public Task<object> ReadAsync()

Result Type: Task<object>

Use<TControllerInterface, TController>()

Register local controller.

public void Use()

Result Type: void

Use<TControllerInterface, TController>(TController)

Register local controller.

public void Use(TController controller)

Result Type: void

Parameters

TypeName
TControllercontrollerController instance.

WriteAsync(object)

Writes object to socket.

public Task WriteAsync(object value)

Result Type: Task

Parameters

TypeName
objectvalueObject to be written on the connection.

Events

Closed

Occurs when connection closes.

public EventHandler<NetworkConnectionClosedEventArgs> Closed

Result Type: EventHandler<NetworkConnectionClosedEventArgs>

ControllerResolve

Occurs when endpoint requests access to controller for the first time.

public EventHandler<NetworkConnectionControllerResolveEventArgs> ControllerResolve

Result Type: EventHandler<NetworkConnectionControllerResolveEventArgs>

Received

Occurs when receives message.

public EventHandler<NetworkConnectionMessageEventArgs> Received

Result Type: EventHandler<NetworkConnectionMessageEventArgs>

ReceivedError

Occurs when it was unable to receive message (eg. deserialization error).

public EventHandler<NetworkConnectionMessageErrorEventArgs> ReceivedError

Result Type: EventHandler<NetworkConnectionMessageErrorEventArgs>