mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-20 04:42:57 +00:00
3.0 wip
This commit is contained in:
@@ -19,15 +19,15 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// <summary>
|
||||
/// Connection lost event
|
||||
/// </summary>
|
||||
public event Action ConnectionLost;
|
||||
public event Action? ConnectionLost;
|
||||
/// <summary>
|
||||
/// Connecting restored event
|
||||
/// </summary>
|
||||
public event Action<TimeSpan> ConnectionRestored;
|
||||
public event Action<TimeSpan>? ConnectionRestored;
|
||||
/// <summary>
|
||||
/// Connecting closed event
|
||||
/// </summary>
|
||||
public event Action Closed;
|
||||
public event Action? Closed;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of handlers
|
||||
@@ -119,7 +119,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// <returns></returns>
|
||||
public SocketSubscription AddHandler(object request, bool userSubscription, Action<SocketConnection, JToken> dataHandler)
|
||||
{
|
||||
var handler = new SocketSubscription(null, request, userSubscription, dataHandler);
|
||||
var handler = new SocketSubscription(request, userSubscription, dataHandler);
|
||||
lock (handlersLock)
|
||||
handlers.Add(handler);
|
||||
return handler;
|
||||
@@ -135,7 +135,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// <returns></returns>
|
||||
public SocketSubscription AddHandler(string identifier, bool userSubscription, Action<SocketConnection, JToken> dataHandler)
|
||||
{
|
||||
var handler = new SocketSubscription(identifier, null, userSubscription, dataHandler);
|
||||
var handler = new SocketSubscription(identifier, userSubscription, dataHandler);
|
||||
lock (handlersLock)
|
||||
handlers.Add(handler);
|
||||
return handler;
|
||||
@@ -169,7 +169,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
|
||||
private bool HandleData(JToken tokenData)
|
||||
{
|
||||
SocketSubscription currentSubscription = null;
|
||||
SocketSubscription? currentSubscription = null;
|
||||
try
|
||||
{
|
||||
var handled = false;
|
||||
@@ -181,7 +181,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
currentSubscription = handler;
|
||||
if (handler.Request == null)
|
||||
{
|
||||
if (socketClient.MessageMatchesHandler(tokenData, handler.Identifier))
|
||||
if (socketClient.MessageMatchesHandler(tokenData, handler.Identifier!))
|
||||
{
|
||||
handled = true;
|
||||
handler.MessageHandler(this, tokenData);
|
||||
@@ -326,7 +326,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
if (Authenticated)
|
||||
{
|
||||
var authResult = await socketClient.AuthenticateSocket(this).ConfigureAwait(false);
|
||||
if (!authResult.Success)
|
||||
if (!authResult)
|
||||
{
|
||||
log.Write(LogVerbosity.Info, "Authentication failed on reconnected socket. Disconnecting and reconnecting.");
|
||||
return false;
|
||||
@@ -343,9 +343,9 @@ namespace CryptoExchange.Net.Sockets
|
||||
var taskList = new List<Task>();
|
||||
foreach (var handler in handlerList)
|
||||
{
|
||||
var task = socketClient.SubscribeAndWait(this, handler.Request, handler).ContinueWith(t =>
|
||||
var task = socketClient.SubscribeAndWait(this, handler.Request!, handler).ContinueWith(t =>
|
||||
{
|
||||
if (!t.Result.Success)
|
||||
if (!t.Result)
|
||||
success = false;
|
||||
});
|
||||
taskList.Add(task);
|
||||
@@ -403,7 +403,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
internal class PendingRequest
|
||||
{
|
||||
public Func<JToken, bool> Handler { get; }
|
||||
public JToken Result { get; private set; }
|
||||
public JToken? Result { get; private set; }
|
||||
public ManualResetEvent Event { get; }
|
||||
public TimeSpan Timeout { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user