Skip to content

Commit

Permalink
Added logging for server pushed error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Mar 1, 2024
1 parent 34768e4 commit d24ecac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mexc.Net/Clients/SpotApi/MexcSocketClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions Mexc.Net/Objects/Sockets/Subscriptions/MexcErrorSubscription.cs
Original file line number Diff line number Diff line change
@@ -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<MexcResponse>
{
public override HashSet<string> ListenerIdentifiers { get; set; } = new HashSet<string> { "0" };

public MexcErrorSubscription(ILogger logger) : base(logger, false)
{
}

public override Task<CallResult> HandleMessageAsync(SocketConnection connection, DataEvent<MexcResponse> message)
{
_logger.LogError("Server Error: {Error}", message.Data.Message);
return Task.FromResult(new CallResult(null));
}
}
}

0 comments on commit d24ecac

Please sign in to comment.