diff --git a/CryptoExchange.Net/Clients/SocketApiClient.cs b/CryptoExchange.Net/Clients/SocketApiClient.cs
index faac4b1..0626864 100644
--- a/CryptoExchange.Net/Clients/SocketApiClient.cs
+++ b/CryptoExchange.Net/Clients/SocketApiClient.cs
@@ -270,7 +270,7 @@ namespace CryptoExchange.Net.Clients
}
var waitEvent = new AsyncResetEvent(false);
- var subQuery = subscription.GetSubQuery(socketConnection);
+ var subQuery = subscription.CreateSubscriptionQuery(socketConnection);
if (subQuery != null)
{
// Send the request and wait for answer
diff --git a/CryptoExchange.Net/Objects/Enums.cs b/CryptoExchange.Net/Objects/Enums.cs
index 179b3a0..3efc973 100644
--- a/CryptoExchange.Net/Objects/Enums.cs
+++ b/CryptoExchange.Net/Objects/Enums.cs
@@ -251,4 +251,20 @@ namespace CryptoExchange.Net.Objects
///
DEX
}
+
+ ///
+ /// Timeout behavior for queries
+ ///
+ public enum TimeoutBehavior
+ {
+ ///
+ /// Fail the request
+ ///
+ Fail,
+ ///
+ /// Mark the query as successful
+ ///
+ Succeed
+ }
+
}
diff --git a/CryptoExchange.Net/Sockets/Query.cs b/CryptoExchange.Net/Sockets/Query.cs
index 56ab226..9d38368 100644
--- a/CryptoExchange.Net/Sockets/Query.cs
+++ b/CryptoExchange.Net/Sockets/Query.cs
@@ -29,6 +29,11 @@ namespace CryptoExchange.Net.Sockets
///
public TimeSpan? RequestTimeout { get; set; }
+ ///
+ /// What should happen if the query times out
+ ///
+ public TimeoutBehavior TimeoutBehavior { get; set; } = TimeoutBehavior.Fail;
+
///
/// 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
@@ -183,7 +188,7 @@ namespace CryptoExchange.Net.Sockets
///
public override async Task Handle(SocketConnection connection, DataEvent
public string? Topic { get; set; }
+ ///
+ /// The subscribe query for this subscription
+ ///
+ public Query? SubscriptionQuery { get; private set; }
+
+ ///
+ /// The unsubscribe query for this subscription
+ ///
+ public Query? UnsubscriptionQuery { get; private set; }
+
///
/// ctor
///
@@ -91,11 +101,21 @@ namespace CryptoExchange.Net.Sockets
Id = ExchangeHelpers.NextId();
}
+ ///
+ /// Create a new subscription query
+ ///
+ public Query? CreateSubscriptionQuery(SocketConnection connection)
+ {
+ var query = GetSubQuery(connection);
+ SubscriptionQuery = query;
+ return query;
+ }
+
///
/// Get the subscribe query to send when subscribing
///
///
- public abstract Query? GetSubQuery(SocketConnection connection);
+ protected abstract Query? GetSubQuery(SocketConnection connection);
///
/// Handle a subscription query response
@@ -109,11 +129,21 @@ namespace CryptoExchange.Net.Sockets
///
public virtual void HandleUnsubQueryResponse(object message) { }
+ ///
+ /// Create a new unsubscription query
+ ///
+ public Query? CreateUnsubscriptionQuery(SocketConnection connection)
+ {
+ var query = GetUnsubQuery(connection);
+ UnsubscriptionQuery = query;
+ return query;
+ }
+
///
/// Get the unsubscribe query to send when unsubscribing
///
///
- public abstract Query? GetUnsubQuery();
+ protected abstract Query? GetUnsubQuery(SocketConnection connection);
///
public virtual CallResult Deserialize(IMessageAccessor message, Type type) => message.Deserialize(type);
diff --git a/CryptoExchange.Net/Sockets/SystemSubscription.cs b/CryptoExchange.Net/Sockets/SystemSubscription.cs
index 1d228ba..97fe449 100644
--- a/CryptoExchange.Net/Sockets/SystemSubscription.cs
+++ b/CryptoExchange.Net/Sockets/SystemSubscription.cs
@@ -22,9 +22,9 @@ namespace CryptoExchange.Net.Sockets
}
///
- public override Query? GetSubQuery(SocketConnection connection) => null;
+ protected override Query? GetSubQuery(SocketConnection connection) => null;
///
- public override Query? GetUnsubQuery() => null;
+ protected override Query? GetUnsubQuery(SocketConnection connection) => null;
}
}