mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-13 17:33:02 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| decef7b137 |
@@ -58,7 +58,9 @@ namespace CryptoExchange.Net.UnitTests
|
|||||||
options.ReconnectInterval = TimeSpan.Zero;
|
options.ReconnectInterval = TimeSpan.Zero;
|
||||||
});
|
});
|
||||||
var socket = client.CreateSocket();
|
var socket = client.CreateSocket();
|
||||||
|
socket.ShouldReconnect = true;
|
||||||
socket.CanConnect = true;
|
socket.CanConnect = true;
|
||||||
|
socket.DisconnectTime = DateTime.UtcNow;
|
||||||
var sub = new SocketConnection(new TraceLogger(), client.SubClient, socket, null);
|
var sub = new SocketConnection(new TraceLogger(), client.SubClient, socket, null);
|
||||||
var rstEvent = new ManualResetEvent(false);
|
var rstEvent = new ManualResetEvent(false);
|
||||||
Dictionary<string, string> result = null;
|
Dictionary<string, string> result = null;
|
||||||
@@ -73,7 +75,7 @@ namespace CryptoExchange.Net.UnitTests
|
|||||||
sub.AddSubscription(subObj);
|
sub.AddSubscription(subObj);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
socket.InvokeMessage("{\"property\": \"123\", \"action\": \"update\", \"topic\": \"topic\"}");
|
socket.InvokeMessage("{\"property\": \"123\", \"topic\": \"topic\"}");
|
||||||
rstEvent.WaitOne(1000);
|
rstEvent.WaitOne(1000);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
@@ -91,7 +93,9 @@ namespace CryptoExchange.Net.UnitTests
|
|||||||
options.SubOptions.OutputOriginalData = enabled;
|
options.SubOptions.OutputOriginalData = enabled;
|
||||||
});
|
});
|
||||||
var socket = client.CreateSocket();
|
var socket = client.CreateSocket();
|
||||||
|
socket.ShouldReconnect = true;
|
||||||
socket.CanConnect = true;
|
socket.CanConnect = true;
|
||||||
|
socket.DisconnectTime = DateTime.UtcNow;
|
||||||
var sub = new SocketConnection(new TraceLogger(), client.SubClient, socket, null);
|
var sub = new SocketConnection(new TraceLogger(), client.SubClient, socket, null);
|
||||||
var rstEvent = new ManualResetEvent(false);
|
var rstEvent = new ManualResetEvent(false);
|
||||||
string original = null;
|
string original = null;
|
||||||
@@ -103,7 +107,7 @@ namespace CryptoExchange.Net.UnitTests
|
|||||||
rstEvent.Set();
|
rstEvent.Set();
|
||||||
});
|
});
|
||||||
sub.AddSubscription(subObj);
|
sub.AddSubscription(subObj);
|
||||||
var msgToSend = JsonConvert.SerializeObject(new { topic = "topic", action = "update", property = 123 });
|
var msgToSend = JsonConvert.SerializeObject(new { topic = "topic", property = 123 });
|
||||||
|
|
||||||
// act
|
// act
|
||||||
socket.InvokeMessage(msgToSend);
|
socket.InvokeMessage(msgToSend);
|
||||||
@@ -198,7 +202,7 @@ namespace CryptoExchange.Net.UnitTests
|
|||||||
|
|
||||||
// act
|
// act
|
||||||
var sub = client.SubClient.SubscribeToSomethingAsync(channel, onUpdate => {}, ct: default);
|
var sub = client.SubClient.SubscribeToSomethingAsync(channel, onUpdate => {}, ct: default);
|
||||||
socket.InvokeMessage(JsonConvert.SerializeObject(new { channel, action = "subscribe", status = "error" }));
|
socket.InvokeMessage(JsonConvert.SerializeObject(new { channel, status = "error" }));
|
||||||
await sub;
|
await sub;
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
@@ -221,7 +225,7 @@ namespace CryptoExchange.Net.UnitTests
|
|||||||
|
|
||||||
// act
|
// act
|
||||||
var sub = client.SubClient.SubscribeToSomethingAsync(channel, onUpdate => {}, ct: default);
|
var sub = client.SubClient.SubscribeToSomethingAsync(channel, onUpdate => {}, ct: default);
|
||||||
socket.InvokeMessage(JsonConvert.SerializeObject(new { channel, action = "subscribe", status = "confirmed" }));
|
socket.InvokeMessage(JsonConvert.SerializeObject(new { channel, status = "confirmed" }));
|
||||||
await sub;
|
await sub;
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations.Sockets
|
|||||||
{
|
{
|
||||||
internal class SubResponse
|
internal class SubResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
[JsonProperty("action")]
|
|
||||||
public string Action { get; set; } = null!;
|
|
||||||
|
|
||||||
[JsonProperty("channel")]
|
[JsonProperty("channel")]
|
||||||
public string Channel { get; set; } = null!;
|
public string Channel { get; set; } = null!;
|
||||||
|
|
||||||
@@ -23,9 +19,6 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations.Sockets
|
|||||||
|
|
||||||
internal class UnsubResponse
|
internal class UnsubResponse
|
||||||
{
|
{
|
||||||
[JsonProperty("action")]
|
|
||||||
public string Action { get; set; } = null!;
|
|
||||||
|
|
||||||
[JsonProperty("status")]
|
[JsonProperty("status")]
|
||||||
public string Status { get; set; } = null!;
|
public string Status { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@@ -36,7 +29,7 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations.Sockets
|
|||||||
|
|
||||||
public TestChannelQuery(string channel, string request, bool authenticated, int weight = 1) : base(request, authenticated, weight)
|
public TestChannelQuery(string channel, string request, bool authenticated, int weight = 1) : base(request, authenticated, weight)
|
||||||
{
|
{
|
||||||
ListenerIdentifiers = new HashSet<string> { request + "-" + channel };
|
ListenerIdentifiers = new HashSet<string> { channel };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override CallResult<SubResponse> HandleMessage(SocketConnection connection, DataEvent<SubResponse> message)
|
public override CallResult<SubResponse> HandleMessage(SocketConnection connection, DataEvent<SubResponse> message)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations.Sockets
|
|||||||
{
|
{
|
||||||
private readonly Action<DataEvent<T>> _handler;
|
private readonly Action<DataEvent<T>> _handler;
|
||||||
|
|
||||||
public override HashSet<string> ListenerIdentifiers { get; set; } = new HashSet<string> { "update-topic" };
|
public override HashSet<string> ListenerIdentifiers { get; set; } = new HashSet<string> { "topic" };
|
||||||
|
|
||||||
public TestSubscription(ILogger logger, Action<DataEvent<T>> handler) : base(logger, false)
|
public TestSubscription(ILogger logger, Action<DataEvent<T>> handler) : base(logger, false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,132 +1,131 @@
|
|||||||
//using System;
|
using System;
|
||||||
//using System.IO;
|
using System.IO;
|
||||||
//using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
//using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
//using System.Text;
|
using System.Text;
|
||||||
//using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
//using CryptoExchange.Net.Interfaces;
|
using CryptoExchange.Net.Interfaces;
|
||||||
//using CryptoExchange.Net.Objects;
|
using CryptoExchange.Net.Objects;
|
||||||
|
|
||||||
//namespace CryptoExchange.Net.UnitTests.TestImplementations
|
namespace CryptoExchange.Net.UnitTests.TestImplementations
|
||||||
//{
|
{
|
||||||
// public class TestSocket: IWebsocket
|
public class TestSocket: IWebsocket
|
||||||
// {
|
{
|
||||||
// public bool CanConnect { get; set; }
|
public bool CanConnect { get; set; }
|
||||||
// public bool Connected { get; set; }
|
public bool Connected { get; set; }
|
||||||
|
|
||||||
// public event Func<Task> OnClose;
|
public event Func<Task> OnClose;
|
||||||
//#pragma warning disable 0067
|
#pragma warning disable 0067
|
||||||
// public event Func<Task> OnReconnected;
|
public event Func<Task> OnReconnected;
|
||||||
// public event Func<Task> OnReconnecting;
|
public event Func<Task> OnReconnecting;
|
||||||
// public event Func<int, Task> OnRequestRateLimited;
|
public event Func<int, Task> OnRequestRateLimited;
|
||||||
//#pragma warning restore 0067
|
#pragma warning restore 0067
|
||||||
// public event Func<int, Task> OnRequestSent;
|
public event Func<int, Task> OnRequestSent;
|
||||||
// public event Func<WebSocketMessageType, ReadOnlyMemory<byte>, Task> OnStreamMessage;
|
public event Action<WebSocketMessageType, ReadOnlyMemory<byte>> OnStreamMessage;
|
||||||
// public event Func<Exception, Task> OnError;
|
public event Func<Exception, Task> OnError;
|
||||||
// public event Func<Task> OnOpen;
|
public event Func<Task> OnOpen;
|
||||||
// public Func<Task<Uri>> GetReconnectionUrl { get; set; }
|
public Func<Task<Uri>> GetReconnectionUrl { get; set; }
|
||||||
|
|
||||||
// public int Id { get; }
|
public int Id { get; }
|
||||||
// public bool ShouldReconnect { get; set; }
|
public bool ShouldReconnect { get; set; }
|
||||||
// public TimeSpan Timeout { get; set; }
|
public TimeSpan Timeout { get; set; }
|
||||||
// public Func<string, string> DataInterpreterString { get; set; }
|
public Func<string, string> DataInterpreterString { get; set; }
|
||||||
// public Func<byte[], string> DataInterpreterBytes { get; set; }
|
public Func<byte[], string> DataInterpreterBytes { get; set; }
|
||||||
// public DateTime? DisconnectTime { get; set; }
|
public DateTime? DisconnectTime { get; set; }
|
||||||
// public string Url { get; }
|
public string Url { get; }
|
||||||
// public bool IsClosed => !Connected;
|
public bool IsClosed => !Connected;
|
||||||
// public bool IsOpen => Connected;
|
public bool IsOpen => Connected;
|
||||||
// public bool PingConnection { get; set; }
|
public bool PingConnection { get; set; }
|
||||||
// public TimeSpan PingInterval { get; set; }
|
public TimeSpan PingInterval { get; set; }
|
||||||
// public SslProtocols SSLProtocols { get; set; }
|
public SslProtocols SSLProtocols { get; set; }
|
||||||
// public Encoding Encoding { get; set; }
|
public Encoding Encoding { get; set; }
|
||||||
|
|
||||||
// public int ConnectCalls { get; private set; }
|
public int ConnectCalls { get; private set; }
|
||||||
// public bool Reconnecting { get; set; }
|
public bool Reconnecting { get; set; }
|
||||||
// public string Origin { get; set; }
|
public string Origin { get; set; }
|
||||||
// public int? RatelimitPerSecond { get; set; }
|
public int? RatelimitPerSecond { get; set; }
|
||||||
|
|
||||||
// public double IncomingKbps => throw new NotImplementedException();
|
public double IncomingKbps => throw new NotImplementedException();
|
||||||
|
|
||||||
// public Uri Uri => new Uri("");
|
public Uri Uri => new Uri("");
|
||||||
|
|
||||||
// public TimeSpan KeepAliveInterval { get; set; }
|
public TimeSpan KeepAliveInterval { get; set; }
|
||||||
|
|
||||||
// public static int lastId = 0;
|
public static int lastId = 0;
|
||||||
// public static object lastIdLock = new object();
|
public static object lastIdLock = new object();
|
||||||
|
|
||||||
// public TestSocket()
|
public TestSocket()
|
||||||
// {
|
{
|
||||||
// lock (lastIdLock)
|
lock (lastIdLock)
|
||||||
// {
|
{
|
||||||
// Id = lastId + 1;
|
Id = lastId + 1;
|
||||||
// lastId++;
|
lastId++;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public Task<CallResult> ConnectAsync()
|
public Task<CallResult> ConnectAsync()
|
||||||
// {
|
{
|
||||||
// Connected = CanConnect;
|
Connected = CanConnect;
|
||||||
// ConnectCalls++;
|
ConnectCalls++;
|
||||||
// if (CanConnect)
|
if (CanConnect)
|
||||||
// InvokeOpen();
|
InvokeOpen();
|
||||||
// return Task.FromResult(CanConnect ? new CallResult(null) : new CallResult(new CantConnectError()));
|
return Task.FromResult(CanConnect ? new CallResult(null) : new CallResult(new CantConnectError()));
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public bool Send(int requestId, string data, int weight)
|
public void Send(int requestId, string data, int weight)
|
||||||
// {
|
{
|
||||||
// if(!Connected)
|
if(!Connected)
|
||||||
// throw new Exception("Socket not connected");
|
throw new Exception("Socket not connected");
|
||||||
// OnRequestSent?.Invoke(requestId);
|
OnRequestSent?.Invoke(requestId);
|
||||||
// return true;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Reset()
|
public void Reset()
|
||||||
// {
|
{
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public Task CloseAsync()
|
public Task CloseAsync()
|
||||||
// {
|
{
|
||||||
// Connected = false;
|
Connected = false;
|
||||||
// DisconnectTime = DateTime.UtcNow;
|
DisconnectTime = DateTime.UtcNow;
|
||||||
// OnClose?.Invoke();
|
OnClose?.Invoke();
|
||||||
// return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void SetProxy(string host, int port)
|
public void SetProxy(string host, int port)
|
||||||
// {
|
{
|
||||||
// throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
// }
|
}
|
||||||
// public void Dispose()
|
public void Dispose()
|
||||||
// {
|
{
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void InvokeClose()
|
public void InvokeClose()
|
||||||
// {
|
{
|
||||||
// Connected = false;
|
Connected = false;
|
||||||
// DisconnectTime = DateTime.UtcNow;
|
DisconnectTime = DateTime.UtcNow;
|
||||||
// Reconnecting = true;
|
Reconnecting = true;
|
||||||
// OnClose?.Invoke();
|
OnClose?.Invoke();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void InvokeOpen()
|
public void InvokeOpen()
|
||||||
// {
|
{
|
||||||
// OnOpen?.Invoke();
|
OnOpen?.Invoke();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void InvokeMessage(string data)
|
public void InvokeMessage(string data)
|
||||||
// {
|
{
|
||||||
// OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory<byte>(Encoding.UTF8.GetBytes(data))).Wait();
|
OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory<byte>(Encoding.UTF8.GetBytes(data)));
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void SetProxy(ApiProxy proxy)
|
public void SetProxy(ApiProxy proxy)
|
||||||
// {
|
{
|
||||||
// throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public void InvokeError(Exception error)
|
public void InvokeError(Exception error)
|
||||||
// {
|
{
|
||||||
// OnError?.Invoke(error);
|
OnError?.Invoke(error);
|
||||||
// }
|
}
|
||||||
// public Task ReconnectAsync() => Task.CompletedTask;
|
public Task ReconnectAsync() => Task.CompletedTask;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ using CryptoExchange.Net.Sockets;
|
|||||||
using CryptoExchange.Net.UnitTests.TestImplementations.Sockets;
|
using CryptoExchange.Net.UnitTests.TestImplementations.Sockets;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Moq;
|
using Moq;
|
||||||
using CryptoExchange.Net.Testing.Implementations;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace CryptoExchange.Net.UnitTests.TestImplementations
|
namespace CryptoExchange.Net.UnitTests.TestImplementations
|
||||||
{
|
{
|
||||||
internal class TestSocketClient: BaseSocketClient
|
public class TestSocketClient: BaseSocketClient
|
||||||
{
|
{
|
||||||
public TestSubSocketClient SubClient { get; }
|
public TestSubSocketClient SubClient { get; }
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
|
|||||||
|
|
||||||
SubClient = AddApiClient(new TestSubSocketClient(options, options.SubOptions));
|
SubClient = AddApiClient(new TestSubSocketClient(options, options.SubOptions));
|
||||||
SubClient.SocketFactory = new Mock<IWebsocketFactory>().Object;
|
SubClient.SocketFactory = new Mock<IWebsocketFactory>().Object;
|
||||||
Mock.Get(SubClient.SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny<ILogger>(), It.IsAny<WebSocketParameters>())).Returns(new TestSocket("https://test.com"));
|
Mock.Get(SubClient.SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny<ILogger>(), It.IsAny<WebSocketParameters>())).Returns(new TestSocket());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestSocket CreateSocket()
|
public TestSocket CreateSocket()
|
||||||
{
|
{
|
||||||
Mock.Get(SubClient.SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny<ILogger>(), It.IsAny<WebSocketParameters>())).Returns(new TestSocket("https://test.com"));
|
Mock.Get(SubClient.SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny<ILogger>(), It.IsAny<WebSocketParameters>())).Returns(new TestSocket());
|
||||||
return (TestSocket)SubClient.CreateSocketInternal("https://localhost:123/");
|
return (TestSocket)SubClient.CreateSocketInternal("https://localhost:123/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,6 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
|
|||||||
public class TestSubSocketClient : SocketApiClient
|
public class TestSubSocketClient : SocketApiClient
|
||||||
{
|
{
|
||||||
private MessagePath _channelPath = MessagePath.Get().Property("channel");
|
private MessagePath _channelPath = MessagePath.Get().Property("channel");
|
||||||
private MessagePath _actionPath = MessagePath.Get().Property("action");
|
|
||||||
private MessagePath _topicPath = MessagePath.Get().Property("topic");
|
private MessagePath _topicPath = MessagePath.Get().Property("topic");
|
||||||
|
|
||||||
public Subscription TestSubscription { get; private set; } = null;
|
public Subscription TestSubscription { get; private set; } = null;
|
||||||
@@ -111,7 +110,7 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
|
|||||||
var id = message.GetValue<string>(_channelPath);
|
var id = message.GetValue<string>(_channelPath);
|
||||||
id ??= message.GetValue<string>(_topicPath);
|
id ??= message.GetValue<string>(_topicPath);
|
||||||
|
|
||||||
return message.GetValue<string>(_actionPath) + "-" + id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<CallResult<UpdateSubscription>> SubscribeToSomethingAsync(string channel, Action<DataEvent<string>> onUpdate, CancellationToken ct)
|
public Task<CallResult<UpdateSubscription>> SubscribeToSomethingAsync(string channel, Action<DataEvent<string>> onUpdate, CancellationToken ct)
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
uriParameters,
|
uriParameters,
|
||||||
bodyParameters,
|
bodyParameters,
|
||||||
additionalHeaders);
|
additionalHeaders);
|
||||||
_logger.RestApiSendRequest(request.RequestId, definition, request.Content, string.IsNullOrEmpty(request.Uri.Query) ? "-" : request.Uri.Query, string.Join(", ", request.GetHeaders().Select(h => h.Key + $"=[{string.Join(",", h.Value)}]")));
|
_logger.RestApiSendRequest(request.RequestId, definition, request.Content, request.Uri.Query, string.Join(", ", request.GetHeaders().Select(h => h.Key + $"=[{string.Join(",", h.Value)}]")));
|
||||||
TotalRequestsMade++;
|
TotalRequestsMade++;
|
||||||
var result = await GetResponseAsync<T>(request, definition.RateLimitGate, cancellationToken).ConfigureAwait(false);
|
var result = await GetResponseAsync<T>(request, definition.RateLimitGate, cancellationToken).ConfigureAwait(false);
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|||||||
@@ -189,10 +189,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
return new CallResult<UpdateSubscription>(new InvalidOperationError("Client disposed, can't subscribe"));
|
return new CallResult<UpdateSubscription>(new InvalidOperationError("Client disposed, can't subscribe"));
|
||||||
|
|
||||||
if (subscription.Authenticated && AuthenticationProvider == null)
|
if (subscription.Authenticated && AuthenticationProvider == null)
|
||||||
{
|
|
||||||
_logger.LogWarning("Failed to subscribe, private subscription but no API credentials set");
|
|
||||||
return new CallResult<UpdateSubscription>(new NoApiCredentialsError());
|
return new CallResult<UpdateSubscription>(new NoApiCredentialsError());
|
||||||
}
|
|
||||||
|
|
||||||
SocketConnection socketConnection;
|
SocketConnection socketConnection;
|
||||||
var released = false;
|
var released = false;
|
||||||
@@ -254,7 +251,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
return new CallResult<UpdateSubscription>(new ServerError("Socket is paused"));
|
return new CallResult<UpdateSubscription>(new ServerError("Socket is paused"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var waitEvent = new AsyncResetEvent(false);
|
var waitEvent = new ManualResetEvent(false);
|
||||||
var subQuery = subscription.GetSubQuery(socketConnection);
|
var subQuery = subscription.GetSubQuery(socketConnection);
|
||||||
if (subQuery != null)
|
if (subQuery != null)
|
||||||
{
|
{
|
||||||
@@ -272,7 +269,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
{
|
{
|
||||||
_logger.FailedToSubscribe(socketConnection.SocketId, subResult.Error?.ToString());
|
_logger.FailedToSubscribe(socketConnection.SocketId, subResult.Error?.ToString());
|
||||||
// If this was a timeout we still need to send an unsubscribe to prevent messages coming in later
|
// If this was a timeout we still need to send an unsubscribe to prevent messages coming in later
|
||||||
await socketConnection.CloseAsync(subscription).ConfigureAwait(false);
|
await socketConnection.CloseAsync(subscription, isTimeout).ConfigureAwait(false);
|
||||||
return new CallResult<UpdateSubscription>(subResult.Error!);
|
return new CallResult<UpdateSubscription>(subResult.Error!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,10 +786,9 @@ namespace CryptoExchange.Net.Clients
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Preprocess a stream message
|
/// Preprocess a stream message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connection"></param>
|
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual ReadOnlyMemory<byte> PreprocessStreamMessage(SocketConnection connection, WebSocketMessageType type, ReadOnlyMemory<byte> data) => data;
|
public virtual ReadOnlyMemory<byte> PreprocessStreamMessage(WebSocketMessageType type, ReadOnlyMemory<byte> data) => data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
public ArrayPropertyAttribute ArrayProperty { get; set; } = null!;
|
public ArrayPropertyAttribute ArrayProperty { get; set; } = null!;
|
||||||
public Type? JsonConverterType { get; set; }
|
public Type? JsonConverterType { get; set; }
|
||||||
public bool DefaultDeserialization { get; set; }
|
public bool DefaultDeserialization { get; set; }
|
||||||
public Type TargetType { get; set; } = null!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ArrayConverterInner<T> : JsonConverter<T>
|
private class ArrayConverterInner<T> : JsonConverter<T>
|
||||||
@@ -71,8 +70,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
ArrayProperty = att,
|
ArrayProperty = att,
|
||||||
PropertyInfo = property,
|
PropertyInfo = property,
|
||||||
DefaultDeserialization = property.GetCustomAttribute<JsonConversionAttribute>() != null,
|
DefaultDeserialization = property.GetCustomAttribute<JsonConversionAttribute>() != null,
|
||||||
JsonConverterType = property.GetCustomAttribute<JsonConverterAttribute>()?.ConverterType,
|
JsonConverterType = property.GetCustomAttribute<JsonConverterAttribute>()?.ConverterType
|
||||||
TargetType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,12 +94,10 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
|
|
||||||
var attribute = attributes.SingleOrDefault(a => a.ArrayProperty.Index == index);
|
var attribute = attributes.SingleOrDefault(a => a.ArrayProperty.Index == index);
|
||||||
if (attribute == null)
|
if (attribute == null)
|
||||||
{
|
|
||||||
index++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
var targetType = attribute.TargetType;
|
var targetType = attribute.PropertyInfo.PropertyType;
|
||||||
|
|
||||||
object? value = null;
|
object? value = null;
|
||||||
if (attribute.JsonConverterType != null)
|
if (attribute.JsonConverterType != null)
|
||||||
{
|
{
|
||||||
@@ -128,7 +124,7 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute.PropertyInfo.SetValue(result, value == null ? null : Convert.ChangeType(value, targetType, CultureInfo.InvariantCulture));
|
attribute.PropertyInfo.SetValue(result, value == null ? null : Convert.ChangeType(value, attribute.PropertyInfo.PropertyType, CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace CryptoExchange.Net.Converters.SystemTextJson
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Read string or number as string
|
|
||||||
/// </summary>
|
|
||||||
public class NumberStringConverter : JsonConverter<string?>
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
if (reader.TokenType == JsonTokenType.Null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (reader.TokenType == JsonTokenType.Number)
|
|
||||||
return reader.GetInt64().ToString();
|
|
||||||
|
|
||||||
return reader.GetString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
writer.WriteStringValue(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -242,7 +242,6 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
{
|
{
|
||||||
_stream?.Dispose();
|
_stream?.Dispose();
|
||||||
_stream = null;
|
_stream = null;
|
||||||
_document?.Dispose();
|
|
||||||
_document = null;
|
_document = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,14 +261,6 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var firstByte = data.Span[0];
|
|
||||||
if (firstByte != 0x7b && firstByte != 0x5b)
|
|
||||||
{
|
|
||||||
// Value doesn't start with `{` or `[`, prevent deserialization attempt as it's slow
|
|
||||||
IsJson = false;
|
|
||||||
return new CallResult(new ServerError("Not a json value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
_document = JsonDocument.Parse(data);
|
_document = JsonDocument.Parse(data);
|
||||||
IsJson = true;
|
IsJson = true;
|
||||||
return new CallResult(null);
|
return new CallResult(null);
|
||||||
@@ -298,7 +289,6 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
public override void Clear()
|
public override void Clear()
|
||||||
{
|
{
|
||||||
_bytes = null;
|
_bytes = null;
|
||||||
_document?.Dispose();
|
|
||||||
_document = null;
|
_document = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
<PackageId>CryptoExchange.Net</PackageId>
|
<PackageId>CryptoExchange.Net</PackageId>
|
||||||
<Authors>JKorf</Authors>
|
<Authors>JKorf</Authors>
|
||||||
<Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description>
|
<Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description>
|
||||||
<PackageVersion>7.10.0</PackageVersion>
|
<PackageVersion>7.8.0</PackageVersion>
|
||||||
<AssemblyVersion>7.10.0</AssemblyVersion>
|
<AssemblyVersion>7.8.0</AssemblyVersion>
|
||||||
<FileVersion>7.10.0</FileVersion>
|
<FileVersion>7.8.0</FileVersion>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange</PackageTags>
|
<PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange</PackageTags>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
@@ -53,11 +53,12 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||||
<PackageReference Include="System.Text.Json" Version="8.0.4" />
|
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -453,7 +453,7 @@ namespace CryptoExchange.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decompress using GzipStream
|
/// Decompress using Gzip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -467,23 +467,6 @@ namespace CryptoExchange.Net
|
|||||||
deflateStream.CopyTo(decompressedStream);
|
deflateStream.CopyTo(decompressedStream);
|
||||||
return new ReadOnlyMemory<byte>(decompressedStream.GetBuffer(), 0, (int)decompressedStream.Length);
|
return new ReadOnlyMemory<byte>(decompressedStream.GetBuffer(), 0, (int)decompressedStream.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Decompress using DeflateStream
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static ReadOnlyMemory<byte> Decompress(this ReadOnlyMemory<byte> input)
|
|
||||||
{
|
|
||||||
var output = new MemoryStream();
|
|
||||||
|
|
||||||
using (var compressStream = new MemoryStream(input.ToArray()))
|
|
||||||
using (var decompressor = new DeflateStream(compressStream, CompressionMode.Decompress))
|
|
||||||
decompressor.CopyTo(output);
|
|
||||||
|
|
||||||
output.Position = 0;
|
|
||||||
return new ReadOnlyMemory<byte>(output.GetBuffer(), 0, (int)output.Length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using CryptoExchange.Net.Objects.Sockets;
|
|||||||
using CryptoExchange.Net.Sockets;
|
using CryptoExchange.Net.Sockets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CryptoExchange.Net.Interfaces
|
namespace CryptoExchange.Net.Interfaces
|
||||||
{
|
{
|
||||||
@@ -26,7 +25,7 @@ namespace CryptoExchange.Net.Interfaces
|
|||||||
/// <param name="connection"></param>
|
/// <param name="connection"></param>
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<CallResult> Handle(SocketConnection connection, DataEvent<object> message);
|
CallResult Handle(SocketConnection connection, DataEvent<object> message);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the type the message should be deserialized to
|
/// Get the type the message should be deserialized to
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace CryptoExchange.Net.Interfaces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Websocket message received event
|
/// Websocket message received event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Func<WebSocketMessageType, ReadOnlyMemory<byte>, Task> OnStreamMessage;
|
event Action<WebSocketMessageType, ReadOnlyMemory<byte>> OnStreamMessage;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Websocket sent event, RequestId as parameter
|
/// Websocket sent event, RequestId as parameter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -78,7 +78,7 @@ namespace CryptoExchange.Net.Interfaces
|
|||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <param name="weight"></param>
|
/// <param name="weight"></param>
|
||||||
bool Send(int id, string data, int weight);
|
void Send(int id, string data, int weight);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reconnect the socket
|
/// Reconnect the socket
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+2
-3
@@ -3,8 +3,7 @@ using System;
|
|||||||
|
|
||||||
namespace CryptoExchange.Net.Logging.Extensions
|
namespace CryptoExchange.Net.Logging.Extensions
|
||||||
{
|
{
|
||||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
internal static class CryptoExchangeWebSocketClientLoggingExtension
|
||||||
public static class CryptoExchangeWebSocketClientLoggingExtension
|
|
||||||
{
|
{
|
||||||
private static readonly Action<ILogger, int, Exception?> _connecting;
|
private static readonly Action<ILogger, int, Exception?> _connecting;
|
||||||
private static readonly Action<ILogger, int, string, Exception?> _connectionFailed;
|
private static readonly Action<ILogger, int, string, Exception?> _connectionFailed;
|
||||||
@@ -152,7 +151,7 @@ namespace CryptoExchange.Net.Logging.Extensions
|
|||||||
"[Sckt {SocketId}] discarding incomplete message of {NumBytes} bytes");
|
"[Sckt {SocketId}] discarding incomplete message of {NumBytes} bytes");
|
||||||
|
|
||||||
_receiveLoopStoppedWithException = LoggerMessage.Define<int>(
|
_receiveLoopStoppedWithException = LoggerMessage.Define<int>(
|
||||||
LogLevel.Error,
|
LogLevel.Warning,
|
||||||
new EventId(1024, "ReceiveLoopStoppedWithException"),
|
new EventId(1024, "ReceiveLoopStoppedWithException"),
|
||||||
"[Sckt {SocketId}] receive loop stopped with exception");
|
"[Sckt {SocketId}] receive loop stopped with exception");
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ using System;
|
|||||||
|
|
||||||
namespace CryptoExchange.Net.Logging.Extensions
|
namespace CryptoExchange.Net.Logging.Extensions
|
||||||
{
|
{
|
||||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
internal static class RateLimitGateLoggingExtensions
|
||||||
public static class RateLimitGateLoggingExtensions
|
|
||||||
{
|
{
|
||||||
private static readonly Action<ILogger, int, string, string, string, Exception?> _rateLimitRequestFailed;
|
private static readonly Action<ILogger, int, string, string, string, Exception?> _rateLimitRequestFailed;
|
||||||
private static readonly Action<ILogger, int, string, string, Exception?> _rateLimitConnectionFailed;
|
private static readonly Action<ILogger, int, string, string, Exception?> _rateLimitConnectionFailed;
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ using System.Net.Http;
|
|||||||
|
|
||||||
namespace CryptoExchange.Net.Logging.Extensions
|
namespace CryptoExchange.Net.Logging.Extensions
|
||||||
{
|
{
|
||||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
internal static class RestApiClientLoggingExtensions
|
||||||
public static class RestApiClientLoggingExtensions
|
|
||||||
{
|
{
|
||||||
private static readonly Action<ILogger, int?, int?, long, string?, Exception?> _restApiErrorReceived;
|
private static readonly Action<ILogger, int?, int?, long, string?, Exception?> _restApiErrorReceived;
|
||||||
private static readonly Action<ILogger, int?, int?, long, string?, Exception?> _restApiResponseReceived;
|
private static readonly Action<ILogger, int?, int?, long, string?, Exception?> _restApiResponseReceived;
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ using System;
|
|||||||
|
|
||||||
namespace CryptoExchange.Net.Logging.Extensions
|
namespace CryptoExchange.Net.Logging.Extensions
|
||||||
{
|
{
|
||||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
internal static class SocketApiClientLoggingExtension
|
||||||
public static class SocketApiClientLoggingExtension
|
|
||||||
{
|
{
|
||||||
private static readonly Action<ILogger, int, Exception?> _failedToAddSubscriptionRetryOnDifferentConnection;
|
private static readonly Action<ILogger, int, Exception?> _failedToAddSubscriptionRetryOnDifferentConnection;
|
||||||
private static readonly Action<ILogger, int, Exception?> _hasBeenPausedCantSubscribeAtThisMoment;
|
private static readonly Action<ILogger, int, Exception?> _hasBeenPausedCantSubscribeAtThisMoment;
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace CryptoExchange.Net.Logging.Extensions
|
namespace CryptoExchange.Net.Logging.Extensions
|
||||||
{
|
{
|
||||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
internal static class SocketConnectionLoggingExtension
|
||||||
public static class SocketConnectionLoggingExtension
|
|
||||||
{
|
{
|
||||||
private static readonly Action<ILogger, int, bool, Exception?> _activityPaused;
|
private static readonly Action<ILogger, int, bool, Exception?> _activityPaused;
|
||||||
private static readonly Action<ILogger, int, Sockets.SocketConnection.SocketStatus, Sockets.SocketConnection.SocketStatus, Exception?> _socketStatusChanged;
|
private static readonly Action<ILogger, int, Sockets.SocketConnection.SocketStatus, Sockets.SocketConnection.SocketStatus, Exception?> _socketStatusChanged;
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace CryptoExchange.Net.Logging.Extensions
|
namespace CryptoExchange.Net.Logging.Extensions
|
||||||
{
|
{
|
||||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
internal static class SymbolOrderBookLoggingExtensions
|
||||||
|
|
||||||
public static class SymbolOrderBookLoggingExtensions
|
|
||||||
{
|
{
|
||||||
private static readonly Action<ILogger, string, string, OrderBookStatus, OrderBookStatus, Exception?> _orderBookStatusChanged;
|
private static readonly Action<ILogger, string, string, OrderBookStatus, OrderBookStatus, Exception?> _orderBookStatusChanged;
|
||||||
private static readonly Action<ILogger, string, string, Exception?> _orderBookStarting;
|
private static readonly Action<ILogger, string, string, Exception?> _orderBookStarting;
|
||||||
|
|||||||
@@ -273,28 +273,6 @@ namespace CryptoExchange.Net.Objects
|
|||||||
return new WebCallResult(ResponseStatusCode, ResponseHeaders, ResponseTime, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, error);
|
return new WebCallResult(ResponseStatusCode, ResponseHeaders, ResponseTime, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Copy the WebCallResult to a new data type
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="K">The new type</typeparam>
|
|
||||||
/// <param name="data">The data of the new type</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public WebCallResult<K> As<K>([AllowNull] K data)
|
|
||||||
{
|
|
||||||
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, 0, null, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, ResultDataSource.Server, data, Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Copy the WebCallResult to a new data type
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="K">The new type</typeparam>
|
|
||||||
/// <param name="error">The error returned</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public WebCallResult<K> AsError<K>(Error error)
|
|
||||||
{
|
|
||||||
return new WebCallResult<K>(ResponseStatusCode, ResponseHeaders, ResponseTime, 0, null, RequestId, RequestUrl, RequestBody, RequestMethod, RequestHeaders, ResultDataSource.Server, default, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,27 +149,6 @@ namespace CryptoExchange.Net.Objects
|
|||||||
Add(key, DateTimeConverter.ConvertToSeconds(value));
|
Add(key, DateTimeConverter.ConvertToSeconds(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a datetime value as string seconds timestamp
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public void AddSecondsString(string key, DateTime value)
|
|
||||||
{
|
|
||||||
Add(key, DateTimeConverter.ConvertToSeconds(value).ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a datetime value as string seconds timestamp. Not added if value is null
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public void AddOptionalSecondsString(string key, DateTime? value)
|
|
||||||
{
|
|
||||||
if (value != null)
|
|
||||||
Add(key, DateTimeConverter.ConvertToSeconds(value).ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an enum value as the string value as mapped using the <see cref="MapAttribute" />
|
/// Add an enum value as the string value as mapped using the <see cref="MapAttribute" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -188,7 +167,7 @@ namespace CryptoExchange.Net.Objects
|
|||||||
public void AddEnumAsInt<T>(string key, T value)
|
public void AddEnumAsInt<T>(string key, T value)
|
||||||
{
|
{
|
||||||
var stringVal = EnumConverter.GetString(value);
|
var stringVal = EnumConverter.GetString(value);
|
||||||
Add(key, int.Parse(stringVal)!);
|
Add(key, EnumConverter.GetString(int.Parse(stringVal))!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -144,11 +144,5 @@ namespace CryptoExchange.Net.Objects.Sockets
|
|||||||
{
|
{
|
||||||
return new CallResult<K>(default, OriginalData, error);
|
return new CallResult<K>(default, OriginalData, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"{StreamId} - {(Symbol == null ? "" : (Symbol + " - "))}{(UpdateType == null ? "" : (UpdateType + " - "))}{Data}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -810,7 +810,7 @@ namespace CryptoExchange.Net.OrderBook
|
|||||||
{
|
{
|
||||||
if (lastUpdateId <= LastSequenceNumber)
|
if (lastUpdateId <= LastSequenceNumber)
|
||||||
{
|
{
|
||||||
_logger.OrderBookUpdateSkipped(Api, Symbol, lastUpdateId, LastSequenceNumber);
|
_logger.OrderBookUpdateSkipped(Api, Symbol, firstUpdateId, lastUpdateId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
public event Func<Task>? OnClose;
|
public event Func<Task>? OnClose;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public event Func<WebSocketMessageType, ReadOnlyMemory<byte>, Task>? OnStreamMessage;
|
public event Action<WebSocketMessageType, ReadOnlyMemory<byte>>? OnStreamMessage;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public event Func<int, Task>? OnRequestSent;
|
public event Func<int, Task>? OnRequestSent;
|
||||||
@@ -245,8 +245,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
await Task.Delay(50).ConfigureAwait(false);
|
await Task.Delay(50).ConfigureAwait(false);
|
||||||
|
|
||||||
await _closeTask.ConfigureAwait(false);
|
await _closeTask.ConfigureAwait(false);
|
||||||
if (!_stopRequested)
|
_closeTask = null;
|
||||||
_closeTask = null;
|
|
||||||
|
|
||||||
if (Parameters.ReconnectPolicy == ReconnectPolicy.Disabled)
|
if (Parameters.ReconnectPolicy == ReconnectPolicy.Disabled)
|
||||||
{
|
{
|
||||||
@@ -323,16 +322,15 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual bool Send(int id, string data, int weight)
|
public virtual void Send(int id, string data, int weight)
|
||||||
{
|
{
|
||||||
if (_ctsSource.IsCancellationRequested || _processState != ProcessState.Processing)
|
if (_ctsSource.IsCancellationRequested)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
var bytes = Parameters.Encoding.GetBytes(data);
|
var bytes = Parameters.Encoding.GetBytes(data);
|
||||||
_logger.SocketAddingBytesToSendBuffer(Id, id, bytes);
|
_logger.SocketAddingBytesToSendBuffer(Id, id, bytes);
|
||||||
_sendBuffer.Enqueue(new SendItem { Id = id, Weight = weight, Bytes = bytes });
|
_sendBuffer.Enqueue(new SendItem { Id = id, Weight = weight, Bytes = bytes });
|
||||||
_sendEvent.Set();
|
_sendEvent.Set();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -391,7 +389,9 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
if (_disposed)
|
if (_disposed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//_closeState = CloseState.Closing;
|
||||||
_ctsSource.Cancel();
|
_ctsSource.Cancel();
|
||||||
|
_sendEvent.Set();
|
||||||
|
|
||||||
if (_socket.State == WebSocketState.Open)
|
if (_socket.State == WebSocketState.Open)
|
||||||
{
|
{
|
||||||
@@ -436,7 +436,6 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
_disposed = true;
|
_disposed = true;
|
||||||
_socket.Dispose();
|
_socket.Dispose();
|
||||||
_ctsSource?.Dispose();
|
_ctsSource?.Dispose();
|
||||||
_sendEvent.Dispose();
|
|
||||||
_logger.SocketDisposed(Id);
|
_logger.SocketDisposed(Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,15 +450,10 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
if (_ctsSource.IsCancellationRequested)
|
||||||
{
|
|
||||||
if (!_sendBuffer.Any())
|
|
||||||
await _sendEvent.WaitAsync(ct: _ctsSource.Token).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (OperationCanceledException)
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
await _sendEvent.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
if (_ctsSource.IsCancellationRequested)
|
if (_ctsSource.IsCancellationRequested)
|
||||||
break;
|
break;
|
||||||
@@ -513,8 +507,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
// Make sure we at least let the owner know there was an error
|
// Make sure we at least let the owner know there was an error
|
||||||
_logger.SocketSendLoopStoppedWithException(Id, e.Message, e);
|
_logger.SocketSendLoopStoppedWithException(Id, e.Message, e);
|
||||||
await (OnError?.Invoke(e) ?? Task.CompletedTask).ConfigureAwait(false);
|
await (OnError?.Invoke(e) ?? Task.CompletedTask).ConfigureAwait(false);
|
||||||
if (_closeTask?.IsCompleted != false)
|
throw;
|
||||||
_closeTask = CloseInternalAsync();
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -589,7 +582,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
{
|
{
|
||||||
// Received a complete message and it's not multi part
|
// Received a complete message and it's not multi part
|
||||||
_logger.SocketReceivedSingleMessage(Id, receiveResult.Count);
|
_logger.SocketReceivedSingleMessage(Id, receiveResult.Count);
|
||||||
await ProcessData(receiveResult.MessageType, new ReadOnlyMemory<byte>(buffer.Array, buffer.Offset, receiveResult.Count)).ConfigureAwait(false);
|
ProcessData(receiveResult.MessageType, new ReadOnlyMemory<byte>(buffer.Array, buffer.Offset, receiveResult.Count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -624,7 +617,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
{
|
{
|
||||||
_logger.SocketReassembledMessage(Id, multipartStream!.Length);
|
_logger.SocketReassembledMessage(Id, multipartStream!.Length);
|
||||||
// Get the underlying buffer of the memorystream holding the written data and delimit it (GetBuffer return the full array, not only the written part)
|
// Get the underlying buffer of the memorystream holding the written data and delimit it (GetBuffer return the full array, not only the written part)
|
||||||
await ProcessData(receiveResult.MessageType, new ReadOnlyMemory<byte>(multipartStream.GetBuffer(), 0, (int)multipartStream.Length)).ConfigureAwait(false);
|
ProcessData(receiveResult.MessageType, new ReadOnlyMemory<byte>(multipartStream.GetBuffer(), 0, (int)multipartStream.Length));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -640,8 +633,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
// Make sure we at least let the owner know there was an error
|
// Make sure we at least let the owner know there was an error
|
||||||
_logger.SocketReceiveLoopStoppedWithException(Id, e);
|
_logger.SocketReceiveLoopStoppedWithException(Id, e);
|
||||||
await (OnError?.Invoke(e) ?? Task.CompletedTask).ConfigureAwait(false);
|
await (OnError?.Invoke(e) ?? Task.CompletedTask).ConfigureAwait(false);
|
||||||
if (_closeTask?.IsCompleted != false)
|
throw;
|
||||||
_closeTask = CloseInternalAsync();
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -655,10 +647,10 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected async Task ProcessData(WebSocketMessageType type, ReadOnlyMemory<byte> data)
|
protected void ProcessData(WebSocketMessageType type, ReadOnlyMemory<byte> data)
|
||||||
{
|
{
|
||||||
LastActionTime = DateTime.UtcNow;
|
LastActionTime = DateTime.UtcNow;
|
||||||
await (OnStreamMessage?.Invoke(type, data) ?? Task.CompletedTask).ConfigureAwait(false);
|
OnStreamMessage?.Invoke(type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -699,6 +691,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
// any exception here will stop the timeout checking, but do so silently unless the socket get's stopped.
|
// any exception here will stop the timeout checking, but do so silently unless the socket get's stopped.
|
||||||
// Make sure we at least let the owner know there was an error
|
// Make sure we at least let the owner know there was an error
|
||||||
await (OnError?.Invoke(e) ?? Task.CompletedTask).ConfigureAwait(false);
|
await (OnError?.Invoke(e) ?? Task.CompletedTask).ConfigureAwait(false);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,14 +716,10 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
var checkTime = DateTime.UtcNow;
|
var checkTime = DateTime.UtcNow;
|
||||||
if (checkTime - _lastReceivedMessagesUpdate > TimeSpan.FromSeconds(1))
|
if (checkTime - _lastReceivedMessagesUpdate > TimeSpan.FromSeconds(1))
|
||||||
{
|
{
|
||||||
for (var i = 0; i < _receivedMessages.Count; i++)
|
foreach (var msg in _receivedMessages.ToList()) // To list here because we're removing from the list
|
||||||
{
|
{
|
||||||
var msg = _receivedMessages[i];
|
|
||||||
if (checkTime - msg.Timestamp > TimeSpan.FromSeconds(3))
|
if (checkTime - msg.Timestamp > TimeSpan.FromSeconds(3))
|
||||||
{
|
|
||||||
_receivedMessages.Remove(msg);
|
_receivedMessages.Remove(msg);
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastReceivedMessagesUpdate = checkTime;
|
_lastReceivedMessagesUpdate = checkTime;
|
||||||
|
|||||||
@@ -24,17 +24,6 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Completed { get; set; }
|
public bool Completed { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The number of required responses. Can be more than 1 when for example subscribing multiple symbols streams in a single request,
|
|
||||||
/// and each symbol receives it's own confirmation response
|
|
||||||
/// </summary>
|
|
||||||
public int RequiredResponses { get; set; } = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The current number of responses received on this query
|
|
||||||
/// </summary>
|
|
||||||
public int CurrentResponses { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Timestamp of when the request was send
|
/// Timestamp of when the request was send
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -53,7 +42,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wait event for the calling message processing thread
|
/// Wait event for the calling message processing thread
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AsyncResetEvent? ContinueAwaiter { get; set; }
|
public ManualResetEvent? ContinueAwaiter { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Strings to match this query to a received message
|
/// Strings to match this query to a received message
|
||||||
@@ -119,7 +108,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wait until timeout or the request is completed
|
/// Wait untill timeout or the request is competed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeout"></param>
|
/// <param name="timeout"></param>
|
||||||
/// <param name="ct">Cancellation token</param>
|
/// <param name="ct">Cancellation token</param>
|
||||||
@@ -146,7 +135,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
/// <param name="connection"></param>
|
/// <param name="connection"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract Task<CallResult> Handle(SocketConnection connection, DataEvent<object> message);
|
public abstract CallResult Handle(SocketConnection connection, DataEvent<object> message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,26 +165,13 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async Task<CallResult> Handle(SocketConnection connection, DataEvent<object> message)
|
public override CallResult Handle(SocketConnection connection, DataEvent<object> message)
|
||||||
{
|
{
|
||||||
CurrentResponses++;
|
Completed = true;
|
||||||
if (CurrentResponses == RequiredResponses)
|
Response = message.Data;
|
||||||
{
|
Result = HandleMessage(connection, message.As((TServerResponse)message.Data));
|
||||||
Completed = true;
|
_event.Set();
|
||||||
Response = message.Data;
|
ContinueAwaiter?.WaitOne();
|
||||||
}
|
|
||||||
|
|
||||||
if (Result?.Success != false)
|
|
||||||
// If an error result is already set don't override that
|
|
||||||
Result = HandleMessage(connection, message.As((TServerResponse)message.Data));
|
|
||||||
|
|
||||||
if (CurrentResponses == RequiredResponses)
|
|
||||||
{
|
|
||||||
_event.Set();
|
|
||||||
if (ContinueAwaiter != null)
|
|
||||||
await ContinueAwaiter.WaitAsync().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -413,14 +413,14 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual async Task HandleStreamMessage(WebSocketMessageType type, ReadOnlyMemory<byte> data)
|
protected virtual void HandleStreamMessage(WebSocketMessageType type, ReadOnlyMemory<byte> data)
|
||||||
{
|
{
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
var receiveTime = DateTime.UtcNow;
|
var receiveTime = DateTime.UtcNow;
|
||||||
string? originalData = null;
|
string? originalData = null;
|
||||||
|
|
||||||
// 1. Decrypt/Preprocess if necessary
|
// 1. Decrypt/Preprocess if necessary
|
||||||
data = ApiClient.PreprocessStreamMessage(this, type, data);
|
data = ApiClient.PreprocessStreamMessage(type, data);
|
||||||
|
|
||||||
// 2. Read data into accessor
|
// 2. Read data into accessor
|
||||||
_accessor.Read(data);
|
_accessor.Read(data);
|
||||||
@@ -507,9 +507,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var innerSw = Stopwatch.StartNew();
|
var innerSw = Stopwatch.StartNew();
|
||||||
await processor.Handle(this, new DataEvent<object>(deserialized, null, null, originalData, receiveTime, null)).ConfigureAwait(false);
|
processor.Handle(this, new DataEvent<object>(deserialized, null, null, originalData, receiveTime, null));
|
||||||
if (processor is Query query && query.RequiredResponses != 1)
|
|
||||||
_logger.LogDebug($"[Sckt {SocketId}] [Req {query.Id}] responses: {query.CurrentResponses}/{query.RequiredResponses}");
|
|
||||||
totalUserTime += (int)innerSw.ElapsedMilliseconds;
|
totalUserTime += (int)innerSw.ElapsedMilliseconds;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -575,8 +573,9 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// Close a subscription on this connection. If all subscriptions on this connection are closed the connection gets closed as well
|
/// Close a subscription on this connection. If all subscriptions on this connection are closed the connection gets closed as well
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="subscription">Subscription to close</param>
|
/// <param name="subscription">Subscription to close</param>
|
||||||
|
/// <param name="unsubEvenIfNotConfirmed">Whether to send an unsub request even if the subscription wasn't confirmed</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task CloseAsync(Subscription subscription)
|
public async Task CloseAsync(Subscription subscription, bool unsubEvenIfNotConfirmed = false)
|
||||||
{
|
{
|
||||||
subscription.Closed = true;
|
subscription.Closed = true;
|
||||||
|
|
||||||
@@ -597,7 +596,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
lock (_listenersLock)
|
lock (_listenersLock)
|
||||||
needUnsub = _listeners.Contains(subscription);
|
needUnsub = _listeners.Contains(subscription);
|
||||||
|
|
||||||
if (needUnsub && _socket.IsOpen)
|
if (needUnsub && (unsubEvenIfNotConfirmed || subscription.Confirmed) && _socket.IsOpen)
|
||||||
await UnsubscribeAsync(subscription).ConfigureAwait(false);
|
await UnsubscribeAsync(subscription).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -698,7 +697,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <param name="continueEvent">Wait event for when the socket message handler can continue</param>
|
/// <param name="continueEvent">Wait event for when the socket message handler can continue</param>
|
||||||
/// <param name="ct">Cancellation token</param>
|
/// <param name="ct">Cancellation token</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<CallResult> SendAndWaitQueryAsync(Query query, AsyncResetEvent? continueEvent = null, CancellationToken ct = default)
|
public virtual async Task<CallResult> SendAndWaitQueryAsync(Query query, ManualResetEvent? continueEvent = null, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
await SendAndWaitIntAsync(query, continueEvent, ct).ConfigureAwait(false);
|
await SendAndWaitIntAsync(query, continueEvent, ct).ConfigureAwait(false);
|
||||||
return query.Result ?? new CallResult(new ServerError("Timeout"));
|
return query.Result ?? new CallResult(new ServerError("Timeout"));
|
||||||
@@ -713,13 +712,13 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <param name="continueEvent">Wait event for when the socket message handler can continue</param>
|
/// <param name="continueEvent">Wait event for when the socket message handler can continue</param>
|
||||||
/// <param name="ct">Cancellation token</param>
|
/// <param name="ct">Cancellation token</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<CallResult<THandlerResponse>> SendAndWaitQueryAsync<TServerResponse, THandlerResponse>(Query<TServerResponse, THandlerResponse> query, AsyncResetEvent? continueEvent = null, CancellationToken ct = default)
|
public virtual async Task<CallResult<THandlerResponse>> SendAndWaitQueryAsync<TServerResponse, THandlerResponse>(Query<TServerResponse, THandlerResponse> query, ManualResetEvent? continueEvent = null, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
await SendAndWaitIntAsync(query, continueEvent, ct).ConfigureAwait(false);
|
await SendAndWaitIntAsync(query, continueEvent, ct).ConfigureAwait(false);
|
||||||
return query.TypedResult ?? new CallResult<THandlerResponse>(new ServerError("Timeout"));
|
return query.TypedResult ?? new CallResult<THandlerResponse>(new ServerError("Timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SendAndWaitIntAsync(Query query, AsyncResetEvent? continueEvent, CancellationToken ct = default)
|
private async Task SendAndWaitIntAsync(Query query, ManualResetEvent? continueEvent, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
lock(_listenersLock)
|
lock(_listenersLock)
|
||||||
_listeners.Add(query);
|
_listeners.Add(query);
|
||||||
@@ -803,9 +802,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
_logger.SendingData(SocketId, requestId, data);
|
_logger.SendingData(SocketId, requestId, data);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_socket.Send(requestId, data, weight))
|
_socket.Send(requestId, data, weight);
|
||||||
return new CallResult(new WebError("Failed to send message, connection not open"));
|
|
||||||
|
|
||||||
return new CallResult(null);
|
return new CallResult(null);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
@@ -835,11 +832,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
|
|
||||||
bool anyAuthenticated;
|
bool anyAuthenticated;
|
||||||
lock (_listenersLock)
|
lock (_listenersLock)
|
||||||
{
|
anyAuthenticated = _listeners.OfType<Subscription>().Any(s => s.Authenticated) || DedicatedRequestConnection;
|
||||||
anyAuthenticated = _listeners.OfType<Subscription>().Any(s => s.Authenticated)
|
|
||||||
|| (DedicatedRequestConnection && ApiClient.AuthenticationProvider != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anyAuthenticated)
|
if (anyAuthenticated)
|
||||||
{
|
{
|
||||||
// If we reconnected a authenticated connection we need to re-authenticate
|
// If we reconnected a authenticated connection we need to re-authenticate
|
||||||
@@ -854,37 +847,36 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
_logger.AuthenticationSucceeded(SocketId);
|
_logger.AuthenticationSucceeded(SocketId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a list of all subscriptions on the socket
|
||||||
|
List<Subscription> subList;
|
||||||
|
lock (_listenersLock)
|
||||||
|
subList = _listeners.OfType<Subscription>().ToList();
|
||||||
|
|
||||||
|
foreach(var subscription in subList)
|
||||||
|
{
|
||||||
|
subscription.ConnectionInvocations = 0;
|
||||||
|
var result = await ApiClient.RevitalizeRequestAsync(subscription).ConfigureAwait(false);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
_logger.FailedRequestRevitalization(SocketId, result.Error?.ToString());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Foreach subscription which is subscribed by a subscription request we will need to resend that request to resubscribe
|
// Foreach subscription which is subscribed by a subscription request we will need to resend that request to resubscribe
|
||||||
int batch = 0;
|
for (var i = 0; i < subList.Count; i += ApiClient.ClientOptions.MaxConcurrentResubscriptionsPerSocket)
|
||||||
int batchSize = ApiClient.ClientOptions.MaxConcurrentResubscriptionsPerSocket;
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
if (!_socket.IsOpen)
|
if (!_socket.IsOpen)
|
||||||
return new CallResult(new WebError("Socket not connected"));
|
return new CallResult(new WebError("Socket not connected"));
|
||||||
|
|
||||||
List<Subscription> subList;
|
|
||||||
lock (_listenersLock)
|
|
||||||
subList = _listeners.OfType<Subscription>().Skip(batch * batchSize).Take(batchSize).ToList();
|
|
||||||
|
|
||||||
if (subList.Count == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
var taskList = new List<Task<CallResult>>();
|
var taskList = new List<Task<CallResult>>();
|
||||||
foreach (var subscription in subList)
|
foreach (var subscription in subList.Skip(i).Take(ApiClient.ClientOptions.MaxConcurrentResubscriptionsPerSocket))
|
||||||
{
|
{
|
||||||
subscription.ConnectionInvocations = 0;
|
|
||||||
var result = await ApiClient.RevitalizeRequestAsync(subscription).ConfigureAwait(false);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
_logger.FailedRequestRevitalization(SocketId, result.Error?.ToString());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
var subQuery = subscription.GetSubQuery(this);
|
var subQuery = subscription.GetSubQuery(this);
|
||||||
if (subQuery == null)
|
if (subQuery == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var waitEvent = new AsyncResetEvent(false);
|
var waitEvent = new ManualResetEvent(false);
|
||||||
taskList.Add(SendAndWaitQueryAsync(subQuery, waitEvent).ContinueWith((r) =>
|
taskList.Add(SendAndWaitQueryAsync(subQuery, waitEvent).ContinueWith((r) =>
|
||||||
{
|
{
|
||||||
subscription.HandleSubQueryResponse(subQuery.Response!);
|
subscription.HandleSubQueryResponse(subQuery.Response!);
|
||||||
@@ -898,8 +890,6 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
await Task.WhenAll(taskList).ConfigureAwait(false);
|
await Task.WhenAll(taskList).ConfigureAwait(false);
|
||||||
if (taskList.Any(t => !t.Result.Success))
|
if (taskList.Any(t => !t.Result.Success))
|
||||||
return taskList.First(t => !t.Result.Success).Result;
|
return taskList.First(t => !t.Result.Success).Result;
|
||||||
|
|
||||||
batch++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_socket.IsOpen)
|
if (!_socket.IsOpen)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CryptoExchange.Net.Sockets
|
namespace CryptoExchange.Net.Sockets
|
||||||
{
|
{
|
||||||
@@ -123,11 +122,11 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <param name="connection"></param>
|
/// <param name="connection"></param>
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<CallResult> Handle(SocketConnection connection, DataEvent<object> message)
|
public CallResult Handle(SocketConnection connection, DataEvent<object> message)
|
||||||
{
|
{
|
||||||
ConnectionInvocations++;
|
ConnectionInvocations++;
|
||||||
TotalInvocations++;
|
TotalInvocations++;
|
||||||
return Task.FromResult(DoHandleMessage(connection, message));
|
return DoHandleMessage(connection, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -75,10 +75,7 @@ namespace CryptoExchange.Net.Testing.Comparers
|
|||||||
var enumerator = list.GetEnumerator();
|
var enumerator = list.GetEnumerator();
|
||||||
foreach (var jObj in jObjs)
|
foreach (var jObj in jObjs)
|
||||||
{
|
{
|
||||||
if (!enumerator.MoveNext())
|
enumerator.MoveNext();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jObj.Type == JTokenType.Object)
|
if (jObj.Type == JTokenType.Object)
|
||||||
{
|
{
|
||||||
foreach (var subProp in ((JObject)jObj).Properties())
|
foreach (var subProp in ((JObject)jObj).Properties())
|
||||||
@@ -275,67 +272,6 @@ namespace CryptoExchange.Net.Testing.Comparers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (propValue.Type == JTokenType.Array)
|
|
||||||
{
|
|
||||||
var jObjs = (JArray)propValue;
|
|
||||||
if (propertyValue is IEnumerable list)
|
|
||||||
{
|
|
||||||
var enumerator = list.GetEnumerator();
|
|
||||||
foreach (var jObj in jObjs)
|
|
||||||
{
|
|
||||||
if (!enumerator.MoveNext())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jObj.Type == JTokenType.Object)
|
|
||||||
{
|
|
||||||
foreach (var subProp in ((JObject)jObj).Properties())
|
|
||||||
{
|
|
||||||
if (ignoreProperties?.Contains(subProp.Name) == true)
|
|
||||||
continue;
|
|
||||||
CheckObject(method, subProp, enumerator.Current, ignoreProperties!);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (jObj.Type == JTokenType.Array)
|
|
||||||
{
|
|
||||||
var resultObj = enumerator.Current;
|
|
||||||
var resultProps = resultObj.GetType().GetProperties().Select(p => (p, p.GetCustomAttributes(typeof(ArrayPropertyAttribute), true).Cast<ArrayPropertyAttribute>().SingleOrDefault()));
|
|
||||||
var arrayConverterProperty = resultObj.GetType().GetCustomAttributes(typeof(JsonConverterAttribute), true).FirstOrDefault();
|
|
||||||
var jsonConverter = ((JsonConverterAttribute)arrayConverterProperty!).ConverterType;
|
|
||||||
if (jsonConverter != typeof(ArrayConverter))
|
|
||||||
// Not array converter?
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach (var item in jObj.Values())
|
|
||||||
{
|
|
||||||
var arrayProp = resultProps.SingleOrDefault(p => p.Item2!.Index == i).p;
|
|
||||||
if (arrayProp != null)
|
|
||||||
CheckPropertyValue(method, item, arrayProp.GetValue(resultObj), arrayProp.PropertyType, arrayProp.Name, "Array index " + i, ignoreProperties!);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var value = enumerator.Current;
|
|
||||||
if (value == default && ((JValue)jObj).Type != JTokenType.Null)
|
|
||||||
throw new Exception($"{method}: Array has no value while input json array has value {jObj}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var resultProps = propertyValue.GetType().GetProperties().Select(p => (p, p.GetCustomAttributes(typeof(ArrayPropertyAttribute), true).Cast<ArrayPropertyAttribute>().SingleOrDefault()));
|
|
||||||
int i = 0;
|
|
||||||
foreach (var item in jObjs.Children())
|
|
||||||
{
|
|
||||||
var arrayProp = resultProps.Where(p => p.Item2 != null).SingleOrDefault(p => p.Item2!.Index == i).p;
|
|
||||||
if (arrayProp != null)
|
|
||||||
CheckPropertyValue(method, item, arrayProp.GetValue(propertyValue), arrayProp.PropertyType, arrayProp.Name, "Array index " + i, ignoreProperties!);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CheckValues(method, propertyName!, propertyType, (JValue)propValue, propertyValue);
|
CheckValues(method, propertyName!, propertyType, (JValue)propValue, propertyValue);
|
||||||
@@ -371,7 +307,7 @@ namespace CryptoExchange.Net.Testing.Comparers
|
|||||||
if (objectValue is DateTime time)
|
if (objectValue is DateTime time)
|
||||||
{
|
{
|
||||||
if (time != DateTimeConverter.ParseFromDouble(jsonValue.Value<long>()!))
|
if (time != DateTimeConverter.ParseFromDouble(jsonValue.Value<long>()!))
|
||||||
throw new Exception($"{method}: {property} not equal: {DateTimeConverter.ParseFromDouble(jsonValue.Value<long>()!)} vs {time}");
|
throw new Exception($"{method}: {property} not equal: {jsonValue.Value<decimal>()} vs {time}");
|
||||||
}
|
}
|
||||||
else if (propertyType.IsEnum || Nullable.GetUnderlyingType(propertyType)?.IsEnum == true)
|
else if (propertyType.IsEnum || Nullable.GetUnderlyingType(propertyType)?.IsEnum == true)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace CryptoExchange.Net.Testing.Implementations
|
|||||||
public event Func<Exception, Task>? OnError;
|
public event Func<Exception, Task>? OnError;
|
||||||
#pragma warning restore 0067
|
#pragma warning restore 0067
|
||||||
public event Func<int, Task>? OnRequestSent;
|
public event Func<int, Task>? OnRequestSent;
|
||||||
public event Func<WebSocketMessageType, ReadOnlyMemory<byte>, Task>? OnStreamMessage;
|
public event Action<WebSocketMessageType, ReadOnlyMemory<byte>>? OnStreamMessage;
|
||||||
public event Func<Task>? OnOpen;
|
public event Func<Task>? OnOpen;
|
||||||
|
|
||||||
public int Id { get; }
|
public int Id { get; }
|
||||||
@@ -33,17 +33,9 @@ namespace CryptoExchange.Net.Testing.Implementations
|
|||||||
public Uri Uri { get; set; }
|
public Uri Uri { get; set; }
|
||||||
public Func<Task<Uri?>>? GetReconnectionUrl { get; set; }
|
public Func<Task<Uri?>>? GetReconnectionUrl { get; set; }
|
||||||
|
|
||||||
public static int lastId = 0;
|
|
||||||
public static object lastIdLock = new object();
|
|
||||||
|
|
||||||
public TestSocket(string address)
|
public TestSocket(string address)
|
||||||
{
|
{
|
||||||
Uri = new Uri(address);
|
Uri = new Uri(address);
|
||||||
lock (lastIdLock)
|
|
||||||
{
|
|
||||||
Id = lastId + 1;
|
|
||||||
lastId++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<CallResult> ConnectAsync()
|
public Task<CallResult> ConnectAsync()
|
||||||
@@ -52,14 +44,13 @@ namespace CryptoExchange.Net.Testing.Implementations
|
|||||||
return Task.FromResult(CanConnect ? new CallResult(null) : new CallResult(new CantConnectError()));
|
return Task.FromResult(CanConnect ? new CallResult(null) : new CallResult(new CantConnectError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Send(int requestId, string data, int weight)
|
public void Send(int requestId, string data, int weight)
|
||||||
{
|
{
|
||||||
if (!Connected)
|
if (!Connected)
|
||||||
throw new Exception("Socket not connected");
|
throw new Exception("Socket not connected");
|
||||||
|
|
||||||
OnRequestSent?.Invoke(requestId);
|
OnRequestSent?.Invoke(requestId);
|
||||||
OnMessageSend?.Invoke(data);
|
OnMessageSend?.Invoke(data);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task CloseAsync()
|
public Task CloseAsync()
|
||||||
@@ -81,12 +72,12 @@ namespace CryptoExchange.Net.Testing.Implementations
|
|||||||
|
|
||||||
public void InvokeMessage(string data)
|
public void InvokeMessage(string data)
|
||||||
{
|
{
|
||||||
OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory<byte>(Encoding.UTF8.GetBytes(data))).Wait();
|
OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory<byte>(Encoding.UTF8.GetBytes(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InvokeMessage<T>(T data)
|
public void InvokeMessage<T>(T data)
|
||||||
{
|
{
|
||||||
OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory<byte>(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data)))).Wait();
|
OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory<byte>(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ReconnectAsync() => throw new NotImplementedException();
|
public Task ReconnectAsync() => throw new NotImplementedException();
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
using CryptoExchange.Net.Objects;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CryptoExchange.Net.Testing
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Base class for executing REST API integration tests
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TClient">Client type</typeparam>
|
|
||||||
public abstract class RestIntergrationTest<TClient>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Get a client instance
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="loggerFactory"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public abstract TClient GetClient(ILoggerFactory loggerFactory);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the test should be run. By default integration tests aren't executed, can be set to true to force execution.
|
|
||||||
/// </summary>
|
|
||||||
public virtual bool Run { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether API credentials are provided and thus authenticated calls can be executed. Should be set in the GetClient implementation.
|
|
||||||
/// </summary>
|
|
||||||
public bool Authenticated { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a client
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected TClient CreateClient()
|
|
||||||
{
|
|
||||||
var fact = new LoggerFactory();
|
|
||||||
fact.AddProvider(new TraceLoggerProvider());
|
|
||||||
return GetClient(fact);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if integration tests should be executed
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected bool ShouldRun()
|
|
||||||
{
|
|
||||||
var integrationTests = Environment.GetEnvironmentVariable("INTEGRATION");
|
|
||||||
if (!Run && integrationTests != "1")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Execute a REST endpoint call and check for any errors or warnings.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Type of response</typeparam>
|
|
||||||
/// <param name="expression">The call expression</param>
|
|
||||||
/// <param name="authRequest">Whether this is an authenticated request</param>
|
|
||||||
public async Task RunAndCheckResult<T>(Expression<Func<TClient, Task<WebCallResult<T>>>> expression, bool authRequest)
|
|
||||||
{
|
|
||||||
if (!ShouldRun())
|
|
||||||
return;
|
|
||||||
|
|
||||||
var client = CreateClient();
|
|
||||||
|
|
||||||
var expressionBody = (MethodCallExpression)expression.Body;
|
|
||||||
if (authRequest && !Authenticated)
|
|
||||||
{
|
|
||||||
Debug.WriteLine($"Skipping {expressionBody.Method.Name}, not authenticated");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var listener = new EnumValueTraceListener();
|
|
||||||
Trace.Listeners.Add(listener);
|
|
||||||
|
|
||||||
WebCallResult<T> result;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result = await expression.Compile().Invoke(client).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new Exception($"Method {expressionBody.Method.Name} threw an exception: " + ex.ToLogString());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Trace.Listeners.Remove(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.Success)
|
|
||||||
throw new Exception($"Method {expressionBody.Method.Name} returned error: " + result.Error);
|
|
||||||
|
|
||||||
Debug.WriteLine($"{expressionBody.Method.Name} {result}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#  CryptoExchange.Net
|
# CryptoExchange.Net
|
||||||
|
|
||||||
[](https://github.com/JKorf/CryptoExchange.Net/actions/workflows/dotnet.yml) [](https://www.nuget.org/packages/CryptoExchange.Net) 
|
[](https://github.com/JKorf/CryptoExchange.Net/actions/workflows/dotnet.yml) [](https://www.nuget.org/packages/CryptoExchange.Net) 
|
||||||
|
|
||||||
@@ -46,28 +46,6 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d
|
|||||||
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
||||||
|
|
||||||
## Release notes
|
## Release notes
|
||||||
* Version 7.10.0 - 26 Jul 2024
|
|
||||||
* Added System.Text.Json NumberStringConverter
|
|
||||||
* Added integration testing base class
|
|
||||||
* Added AddSecondsString and AddOptionalSecondsString to ParameterCollection
|
|
||||||
* Added Decompress method for ReadOnlyMemory using non-GZip deflate
|
|
||||||
* Added SocketConnection parameter to SocketConnection PreprocessStreamMessage
|
|
||||||
* Fixed websocket reconnect/unsubscribe timing bug
|
|
||||||
* Fixed issue in System.Text.Json array object deserialization skipping property when skipping an index
|
|
||||||
* Fixed order book logging bug
|
|
||||||
* Fixed bug in ParameterCollection AddEnumAsInt
|
|
||||||
|
|
||||||
* Version 7.9.0 - 16 Jul 2024
|
|
||||||
* Added some checks in websocket connection handling
|
|
||||||
* Added As<T> and AsError<T> methods on untyped WebCallResult
|
|
||||||
* Updated System.Text.Json package to version 8.0.4 to fix vulnerability
|
|
||||||
* Updated websocket subscription response handling to remove the thread blocking ManualResetEvent usage
|
|
||||||
* Updated static logging classes access modifier from internal to public so they can be called in overriden methods
|
|
||||||
* Updated some testing object implementations
|
|
||||||
* Fixed authentication error when reconnecting an unauthenticated connection which was marked as dedicated query connection
|
|
||||||
* Small improvements in SystemTextJsonMessageAccessor
|
|
||||||
* Fixed System.Text.Json ArrayConverter implementation nullable value types handling
|
|
||||||
|
|
||||||
* Version 7.8.0 - 02 Jul 2024
|
* Version 7.8.0 - 02 Jul 2024
|
||||||
* Updated single endpoint limit configuration
|
* Updated single endpoint limit configuration
|
||||||
* Added LongConverter for nullable longs
|
* Added LongConverter for nullable longs
|
||||||
|
|||||||
+1
-1
@@ -1389,7 +1389,7 @@ await client.UnsubscribeAllAsync();</code></pre>
|
|||||||
============================ -->
|
============================ -->
|
||||||
<section id="idocs_common">
|
<section id="idocs_common">
|
||||||
<h2>Common Clients</h2>
|
<h2>Common Clients</h2>
|
||||||
<p>The CryptoClients.Net library exposes two client classes. These clients aim to make using the different API's easier.</p>
|
<p>The CryptoClients.Net client exposes some common client classes. These clients aim to make using the different API's easier.</p>
|
||||||
|
|
||||||
<p><b>(I)ExchangeRestClient</b><br />
|
<p><b>(I)ExchangeRestClient</b><br />
|
||||||
The <code>IExchangeRestClient</code> (or <code>ExchangeRestClient</code> when used directly) can be used to easily access REST clients for different API's.
|
The <code>IExchangeRestClient</code> (or <code>ExchangeRestClient</code> when used directly) can be used to easily access REST clients for different API's.
|
||||||
|
|||||||
Reference in New Issue
Block a user