Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Mar 12, 2024
1 parent f1bc3f4 commit d8ac0ec
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions BingX.Net/BingX.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BingX.Net/Clients/SpotApi/BingXRestClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal BingXRestClientSpotApi(ILogger logger, HttpClient? httpClient, BingXRes
/// <inheritdoc />
protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();
/// <inheritdoc />
protected override IMessageAccessor CreateAccessor() => new SystemTextJsonMessageAccessor();
protected override IStreamMessageAccessor CreateAccessor() => new SystemTextJsonStreamMessageAccessor();

/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
Expand Down
10 changes: 5 additions & 5 deletions BingX.Net/Clients/SpotApi/BingXSocketClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected override AuthenticationProvider CreateAuthenticationProvider(ApiCreden
/// <inheritdoc />
protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();
/// <inheritdoc />
protected override IMessageAccessor CreateAccessor() => new SystemTextJsonMessageAccessor();
protected override IByteMessageAccessor CreateAccessor() => new SystemTextJsonByteMessageAccessor();

/// <inheritdoc />
public async Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(string symbol, Action<DataEvent<BingXTradeUpdate>> onMessage, CancellationToken ct = default)
Expand Down Expand Up @@ -122,16 +122,16 @@ public async Task<CallResult<UpdateSubscription>> SubscribeToBalanceUpdatesAsync
}

/// <inheritdoc />
public override Stream PreprocessStreamMessage(WebSocketMessageType type, Stream stream)
public override ReadOnlyMemory<byte> PreprocessStreamMessage(WebSocketMessageType type, ReadOnlyMemory<byte> data)
{
if (type != WebSocketMessageType.Binary)
return stream;
return data;

var decompressedStream = new MemoryStream();
using var deflateStream = new GZipStream(stream, CompressionMode.Decompress);
using var deflateStream = new GZipStream(new MemoryStream(data.ToArray()), CompressionMode.Decompress);
deflateStream.CopyTo(decompressedStream);
decompressedStream.Position = 0;
return decompressedStream;
return new ReadOnlyMemory<byte>(decompressedStream.ToArray());
}

/// <inheritdoc />
Expand Down
6 changes: 3 additions & 3 deletions BingX.Net/Objects/Sockets/BingXQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public BingXQuery(BingXSocketRequest request, bool authenticated, int weight = 1
ListenerIdentifiers = new HashSet<string> { request.Id };
}

public override Task<CallResult<BingXSocketResponse>> HandleMessageAsync(SocketConnection connection, DataEvent<BingXSocketResponse> message)
public override CallResult<BingXSocketResponse> HandleMessage(SocketConnection connection, DataEvent<BingXSocketResponse> message)
{
if (message.Data.Code != 0)
return Task.FromResult(new CallResult<BingXSocketResponse>(new ServerError(message.Data.Code, message.Data.Message!), message.OriginalData));
return new CallResult<BingXSocketResponse>(new ServerError(message.Data.Code, message.Data.Message!), message.OriginalData);

return Task.FromResult(new CallResult<BingXSocketResponse>(message.Data, message.OriginalData, null));
return new CallResult<BingXSocketResponse>(message.Data, message.OriginalData, null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public BingXPingSubscription(ILogger logger) : base(logger, false)
{
}

public override Task<CallResult> HandleMessageAsync(SocketConnection connection, DataEvent<BingXPing> message)
public override CallResult HandleMessage(SocketConnection connection, DataEvent<BingXPing> message)
{
connection.Send(ExchangeHelpers.NextId(), new BingXPong { Pong = message.Data.Ping, Timestamp = message.Data.Timestamp }, 1);
return Task.FromResult(new CallResult(null));
return new CallResult(null);
}
}
}
4 changes: 2 additions & 2 deletions BingX.Net/Objects/Sockets/Subscriptions/BingXSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public BingXSubscription(ILogger logger, string dataType, string listenId, Actio
}, false);

/// <inheritdoc />
public override Task<CallResult> DoHandleMessageAsync(SocketConnection connection, DataEvent<object> message)
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
var update = (BingXUpdate<T>)message.Data;
_handler.Invoke(message.As(update.Data!, update.DataType, SocketUpdateType.Update));
return Task.FromResult(new CallResult(null));
return new CallResult(null);
}
}
}

0 comments on commit d8ac0ec

Please sign in to comment.