DarkWS.Client.IDarkWsClient
DarkWS.Client
DarkWS.Client
IDarkWsClient Interface
One logical connection and server session. Safe for concurrent callers.
public interface IDarkWsClient : System.IDisposable, System.IAsyncDisposable
Derived
↳ DarkWsClient
Implements System.IDisposable, System.IAsyncDisposable
Properties
IDarkWsClient.State Property
Current connection readiness.
DarkWS.Client.DarkWsClientState State { get; }
Property Value
Methods
IDarkWsClient.AuthenticateAsync(string, CancellationToken) Method
Waits for acknowledged authentication. The supplied token is not retained for reconnect.
System.Threading.Tasks.Task AuthenticateAsync(string token, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
token System.String
cancellationToken System.Threading.CancellationToken
Returns
IDarkWsClient.CloseAsync(CancellationToken) Method
Stops reconnect and closes the socket. Explicit ConnectAsync allows reuse.
System.Threading.Tasks.Task CloseAsync(System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
cancellationToken System.Threading.CancellationToken
Returns
IDarkWsClient.ConnectAsync(CancellationToken) Method
Starts or joins a connection cycle. Cancelling the wait does not stop other callers.
System.Threading.Tasks.Task ConnectAsync(System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
cancellationToken System.Threading.CancellationToken
Returns
IDarkWsClient.LogoutAsync(CancellationToken) Method
Disables automatic session authentication and waits for acknowledged logout.
System.Threading.Tasks.Task LogoutAsync(System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
cancellationToken System.Threading.CancellationToken
Returns
IDarkWsClient.On(string, Action) Method
Subscribes to an action, ignoring its optional payload. Dispose to unsubscribe.
System.IDisposable On(string action, System.Action handler);
Parameters
action System.String
handler System.Action
Returns
IDarkWsClient.On<T>(string, Action<T>) Method
Subscribes to typed action data. Callbacks run off the UI context, in delivery order.
System.IDisposable On<T>(string action, System.Action<T> handler);
Type parameters
T
Parameters
action System.String
handler System.Action<T>
Returns
IDarkWsClient.OnAsync<T>(string, Func<T,CancellationToken,Task>) Method
Subscribes to async typed callbacks. Cancellation signals loss of the originating connection.
System.IDisposable OnAsync<T>(string action, System.Func<T,System.Threading.CancellationToken,System.Threading.Tasks.Task> handler);
Type parameters
T
Parameters
action System.String
handler System.Func<T,System.Threading.CancellationToken,System.Threading.Tasks.Task>
Returns
IDarkWsClient.RequestAsync(string, object, CancellationToken) Method
Sends a payload and waits for success, ignoring returned data.
System.Threading.Tasks.Task RequestAsync(string action, object? payload, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
action System.String
payload System.Object
cancellationToken System.Threading.CancellationToken
Returns
IDarkWsClient.RequestAsync(string, CancellationToken) Method
Sends a request without a payload and waits for success, ignoring returned data.
System.Threading.Tasks.Task RequestAsync(string action, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
action System.String
cancellationToken System.Threading.CancellationToken
Returns
IDarkWsClient.RequestAsync<TResponse>(string, object, CancellationToken) Method
Sends a payload, including explicit null, and deserializes the required data field.
System.Threading.Tasks.Task<TResponse> RequestAsync<TResponse>(string action, object? payload, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Type parameters
TResponse
Parameters
action System.String
payload System.Object
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<TResponse>
IDarkWsClient.RequestAsync<TResponse>(string, CancellationToken) Method
Sends a request without a payload and deserializes its required data field.
System.Threading.Tasks.Task<TResponse> RequestAsync<TResponse>(string action, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Type parameters
TResponse
Parameters
action System.String
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<TResponse>
Events
IDarkWsClient.Error Event
Background and subscriber errors. Request errors are returned through their tasks.
event EventHandler<DarkWsClientErrorEventArgs>? Error;
Event Type
System.EventHandler<DarkWsClientErrorEventArgs>
IDarkWsClient.StateChanged Event
Ordered state transitions delivered outside the socket reader and internal locks.
event EventHandler<DarkWsStateChangedEventArgs>? StateChanged;