Interface IClientManager<TKey, TClient>
Manages connections lifetime to the selected keys.
Inherited Members
Namespace: Microsoft.XboxStudios.ClientManager
Assembly: ClientManager.Abstractions.dll
Syntax
public interface IClientManager<TKey, TClient> : IClientManager<TKey>, ICanDisconnect<TKey>, IHoldsBaggage<TKey> where TKey : notnull where TClient : class
Type Parameters
| Name | Description |
|---|---|
| TKey | The key to use to identify a specific client. |
| TClient | The type of the client used for connections. |
Remarks
If using client manager as a singleton, make sure to unsubscribe from its events on cleanup.
Methods
View SourceCreateScope()
Creates a connection scope to manage reservations.
Declaration
IConnectionScope<TKey, TClient> CreateScope()
Returns
| Type | Description |
|---|---|
| IConnectionScope<TKey, TClient> | A connection scope. |
NeedsToConnect(TClient)
Checks whether a client needs to connect or not.
Declaration
bool NeedsToConnect(TClient client)
Parameters
| Type | Name | Description |
|---|---|---|
| TClient | client | The client to check for. |
Returns
| Type | Description |
|---|---|
| bool | True if client needs to connect. False otherwise. |
Reserve(TKey)
Reserves the client for a specific TKey.
Callers are responsible to dispose of the reserved client.
Declaration
Reserved<TClient>? Reserve(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to use. |
Returns
| Type | Description |
|---|---|
| Reserved<TClient> | The client assosciated with the requested key. |
ReserveAndConnectAsync(TKey, CancellationOptions?)
Reserves the client for a specific TKey and establishes connection if necessary.
Callers are responsible to dispose of the reserved client.
Declaration
ValueTask<Reserved<TClient>?> ReserveAndConnectAsync(TKey key, CancellationOptions? co = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to use. |
| CancellationOptions? | co | The Microsoft.XboxStudios.Bifrost.CancellationOptions. |
Returns
| Type | Description |
|---|---|
| ValueTask<Reserved<TClient>> | The client assosciated with the requested key. Null if connection failed. |
Events
View SourceOnConnected
Event triggered when client has connected.
Declaration
event EventHandler<TClient>? OnConnected
Event Type
| Type | Description |
|---|---|
| EventHandler<TClient> |
OnConnecting
Event triggered when client is connecting.
Declaration
event EventHandler<TClient>? OnConnecting
Event Type
| Type | Description |
|---|---|
| EventHandler<TClient> |
OnConnectionChanged
Event triggered when connection changes on a client.
Declaration
event EventHandler<(TKey Key, TClient Client)>? OnConnectionChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<(TKey Key, TClient Client)> |
OnDisconnected
Event triggered when client has disconnected.
Declaration
event EventHandler<TClient>? OnDisconnected
Event Type
| Type | Description |
|---|---|
| EventHandler<TClient> |
OnDisconnecting
Event triggered when client is disconnecting.
Declaration
event EventHandler<TClient>? OnDisconnecting
Event Type
| Type | Description |
|---|---|
| EventHandler<TClient> |