Class ConnectionScope<TKey, TClient>
Auto reserves clients and manages their lifetime.
Implements
Inherited Members
Namespace: Microsoft.XboxStudios.ClientManager
Assembly: ClientManager.dll
Syntax
public class ConnectionScope<TKey, TClient> : ClientScopeBase<TKey>, IEnumerable<TKey>, IEnumerable, IConnectionScope<TKey, TClient>, IConnectionScope<TKey>, ICanConnect<TKey>, IHoldsBaggage<TKey>, IAsyncDisposable, IDisposable where TKey : notnull where TClient : class
Type Parameters
Name | Description |
---|---|
TKey | The type of key to use. |
TClient | The type of client to use. |
Remarks
Initializes a new instance of the ConnectionScope<TKey, TClient> class.
Constructors
View SourceConnectionScope(IClientManager<TKey, TClient>)
Auto reserves clients and manages their lifetime.
Declaration
public ConnectionScope(IClientManager<TKey, TClient> clientManager)
Parameters
Type | Name | Description |
---|---|---|
IClientManager<TKey, TClient> | clientManager | The client manager used to establish connections. |
Remarks
Initializes a new instance of the ConnectionScope<TKey, TClient> class.
Methods
View SourceConnectAndGetBaggageAsync<TBaggage>(TKey, CancellationOptions?)
Connects if necessary and gets the baggage associated with a key.
Declaration
public virtual ValueTask<TBaggage> ConnectAndGetBaggageAsync<TBaggage>(TKey key, CancellationOptions? co = null)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The TKey to use to fetch a baggage. |
CancellationOptions? | co | The Microsoft.XboxStudios.Bifrost.CancellationOptions. |
Returns
Type | Description |
---|---|
ValueTask<TBaggage> | The baggage if possible. |
Type Parameters
Name | Description |
---|---|
TBaggage | The type of the baggage. |
Exceptions
Type | Condition |
---|---|
BaggageNullException | Thrown if the registered baggage factory returned null. |
ConnectionFailedException | Thrown if the connection could not be established. |
MissingBaggageFactoryException | Thrown if the baggage factory of the requested baggage is not registered. |
ConnectAndGetClientAsync(TKey, CancellationOptions?)
Connects if necessary and gets the client associated with a key.
Declaration
public ValueTask<TClient?> ConnectAndGetClientAsync(TKey key, CancellationOptions? co = null)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The TKey to use to fetch a baggage. |
CancellationOptions? | co | The Microsoft.XboxStudios.Bifrost.CancellationOptions. |
Returns
Type | Description |
---|---|
ValueTask<TClient> | The client if possible, null otherwise. |
ConnectAsync(TKey, CancellationOptions?)
Connects a client to a game instance.
Declaration
public override ValueTask<bool> ConnectAsync(TKey key, CancellationOptions? co = null)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The TKey to use to fetch a client and attempt a connection. |
CancellationOptions? | co | The Microsoft.XboxStudios.Bifrost.CancellationOptions. |
Returns
Type | Description |
---|---|
ValueTask<bool> | A value indicating whether connection was successful or not. |
Overrides
View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask | A task that represents the asynchronous dispose operation. |
GetBaggage<TBaggage>(TKey)
Gets the baggage associated with a key.
Declaration
public override TBaggage GetBaggage<TBaggage>(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The TKey to use to fetch a baggage. |
Returns
Type | Description |
---|---|
TBaggage | The baggage or null if no connection exists. |
Type Parameters
Name | Description |
---|---|
TBaggage | The type of the baggage. |
Overrides
Exceptions
Type | Condition |
---|---|
BaggageNullException | Thrown if the registered baggage factory returned null. |
MissingBaggageFactoryException | Thrown if the baggage factory of the requested baggage is not registered. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public override IEnumerator<TKey> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<TKey> | An enumerator that can be used to iterate through the collection. |
Overrides
View SourceRemoveConnection(TKey)
Removes the connection associated with the key if active.
Declaration
public void RemoveConnection(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to remove the state for. |