diff --git a/Mexc.Net/Clients/SpotApi/MexcSocketClientSpotApi.cs b/Mexc.Net/Clients/SpotApi/MexcSocketClientSpotApi.cs index b9556d9..d2cb9b8 100644 --- a/Mexc.Net/Clients/SpotApi/MexcSocketClientSpotApi.cs +++ b/Mexc.Net/Clients/SpotApi/MexcSocketClientSpotApi.cs @@ -35,6 +35,7 @@ public class MexcSocketClientSpotApi : SocketApiClient, IMexcSocketClientSpotApi internal MexcSocketClientSpotApi(ILogger logger, MexcSocketOptions options) : base(logger, options.Environment.SpotSocketAddress, options, options.SpotOptions) { + AddSystemSubscription(new MexcErrorSubscription(_logger)); } #endregion diff --git a/Mexc.Net/Objects/Sockets/Subscriptions/MexcErrorSubscription.cs b/Mexc.Net/Objects/Sockets/Subscriptions/MexcErrorSubscription.cs new file mode 100644 index 0000000..c842bc5 --- /dev/null +++ b/Mexc.Net/Objects/Sockets/Subscriptions/MexcErrorSubscription.cs @@ -0,0 +1,25 @@ +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using Mexc.Net.Objects.Sockets.Models; +using Microsoft.Extensions.Logging; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Mexc.Net.Objects.Sockets.Subscriptions +{ + internal class MexcErrorSubscription : SystemSubscription + { + public override HashSet ListenerIdentifiers { get; set; } = new HashSet { "0" }; + + public MexcErrorSubscription(ILogger logger) : base(logger, false) + { + } + + public override Task HandleMessageAsync(SocketConnection connection, DataEvent message) + { + _logger.LogError("Server Error: {Error}", message.Data.Message); + return Task.FromResult(new CallResult(null)); + } + } +}