diff --git a/CryptoExchange.Net/SharedApis/SharedApiClientBase.cs b/CryptoExchange.Net/SharedApis/SharedApiClientBase.cs index 09f83740..507522da 100644 --- a/CryptoExchange.Net/SharedApis/SharedApiClientBase.cs +++ b/CryptoExchange.Net/SharedApis/SharedApiClientBase.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading.Tasks; namespace CryptoExchange.Net.SharedApis { @@ -104,6 +105,11 @@ namespace CryptoExchange.Net.SharedApis SharedCapabilityResolution? GetCapability(SharedCapabilityReference capability, TradingMode tradingMode) where T : ISharedApiCapability; + /// + /// Unsubscribes all subscriptions created by the underlying socket API + /// client and closes its subscription connections. + /// + Task UnsubscribeAllAsync(); } /// @@ -209,6 +215,15 @@ namespace CryptoExchange.Net.SharedApis return GetCapabilities(tradingMode); } + /// + public Task UnsubscribeAllAsync() + { + return Task.WhenAll( + _sharedApis + .OfType() + .Select(x => x.UnsubscribeAllAsync())); + } + object? ISharedApiClientResolver.GetCapability(Type capabilityType) { return _sharedApis diff --git a/CryptoExchange.Net/SharedApis/V2/ISharedSubscription.cs b/CryptoExchange.Net/SharedApis/V2/ISharedSubscription.cs index 1d6cd387..159a9e47 100644 --- a/CryptoExchange.Net/SharedApis/V2/ISharedSubscription.cs +++ b/CryptoExchange.Net/SharedApis/V2/ISharedSubscription.cs @@ -1,13 +1,19 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; namespace CryptoExchange.Net.SharedApis { /// - /// Shared WebSocket API subscription capabitlity + /// Shared WebSocket API subscription capability /// public interface ISharedSubscription : ISharedSocket { + /// + /// Unsubscribes all subscriptions created by the underlying socket API + /// client and closes its subscription connections. + /// + Task UnsubscribeAllAsync(); } }