Table of Contents

Class ConnectionStateTracker

Namespace
Ecng.Net
Assembly
Ecng.Net.SocketIO.dll

Tracks the connection states of multiple IConnection instances and aggregates their overall state.

public class ConnectionStateTracker : Disposable, IDisposable, IConnection
Inheritance
ConnectionStateTracker
Implements
Inherited Members
Extension Methods

Constructors

ConnectionStateTracker()

public ConnectionStateTracker()

Methods

Add(IConnection)

Adds a connection to be tracked.

public void Add(IConnection connection)

Parameters

connection IConnection

The connection to add.

ConnectAsync(CancellationToken)

Connects all tracked connections asynchronously.

public ValueTask ConnectAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation.

Returns

ValueTask

A task that represents the asynchronous connect operation.

Exceptions

InvalidOperationException

Thrown when there are no connections to connect.

Disconnect()

Disconnects all tracked connections.

public void Disconnect()

DisposeManaged()

Releases the managed resources used by the ConnectionStateTracker.

protected override void DisposeManaged()

Remove(IConnection)

Removes a tracked connection.

public bool Remove(IConnection connection)

Parameters

connection IConnection

The connection to remove.

Returns

bool

True if the connection was successfully removed; otherwise, false.

Events

StateChanged

Occurs when the overall connection state changes.

public event Action<ConnectionStates> StateChanged

Event Type

Action<ConnectionStates>