mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-10 09:26:22 +00:00
Added paused activity socket events
This commit is contained in:
parent
d459102323
commit
66c0b90016
@ -2689,6 +2689,16 @@
|
||||
Connecting restored event
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.SocketConnection.ActivityPaused">
|
||||
<summary>
|
||||
The connection is paused event
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.SocketConnection.ActivityUnpaused">
|
||||
<summary>
|
||||
The connection is unpaused event
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.SocketConnection.Closed">
|
||||
<summary>
|
||||
Connecting closed event
|
||||
@ -2858,6 +2868,16 @@
|
||||
Event when the connection is restored. Timespan parameter indicates the time the socket has been offline for before reconnecting
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.UpdateSubscription.ActivityPaused">
|
||||
<summary>
|
||||
Event when the connection to the server is paused. No operations can be performed while paused
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.UpdateSubscription.ActivityUnpaused">
|
||||
<summary>
|
||||
Event when the connection to the server is unpaused
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.UpdateSubscription.Exception">
|
||||
<summary>
|
||||
Event when an exception happened
|
||||
|
@ -161,6 +161,11 @@ namespace CryptoExchange.Net
|
||||
semaphoreSlim.Release();
|
||||
}
|
||||
|
||||
if (socket.PausedActivity)
|
||||
{
|
||||
log.Write(LogVerbosity.Info, "Socket has been paused, can't subscribe at this moment");
|
||||
return new CallResult<UpdateSubscription>(default, new ServerError("Socket is paused"));
|
||||
}
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
|
@ -25,6 +25,14 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// </summary>
|
||||
public event Action<TimeSpan>? ConnectionRestored;
|
||||
/// <summary>
|
||||
/// The connection is paused event
|
||||
/// </summary>
|
||||
public event Action? ActivityPaused;
|
||||
/// <summary>
|
||||
/// The connection is unpaused event
|
||||
/// </summary>
|
||||
public event Action? ActivityUnpaused;
|
||||
/// <summary>
|
||||
/// Connecting closed event
|
||||
/// </summary>
|
||||
public event Action? Closed;
|
||||
@ -60,11 +68,26 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// Time of disconnecting
|
||||
/// </summary>
|
||||
public DateTime? DisconnectTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If activity is paused
|
||||
/// </summary>
|
||||
public bool PausedActivity { get; set; }
|
||||
public bool PausedActivity
|
||||
{
|
||||
get => pausedActivity;
|
||||
set
|
||||
{
|
||||
if (pausedActivity != value)
|
||||
{
|
||||
pausedActivity = value;
|
||||
log.Write(LogVerbosity.Debug, "Paused activity: " + value);
|
||||
if(pausedActivity) ActivityPaused?.Invoke();
|
||||
else ActivityUnpaused?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool pausedActivity;
|
||||
private readonly List<SocketSubscription> handlers;
|
||||
private readonly object handlersLock = new object();
|
||||
|
||||
@ -155,7 +178,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
var sw = Stopwatch.StartNew();
|
||||
lock (handlersLock)
|
||||
{
|
||||
foreach (var handler in handlers)
|
||||
foreach (var handler in handlers.ToList())
|
||||
{
|
||||
currentSubscription = handler;
|
||||
if (handler.Request == null)
|
||||
|
@ -29,6 +29,24 @@ namespace CryptoExchange.Net.Sockets
|
||||
remove => connection.ConnectionRestored -= value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event when the connection to the server is paused. No operations can be performed while paused
|
||||
/// </summary>
|
||||
public event Action ActivityPaused
|
||||
{
|
||||
add => connection.ActivityPaused += value;
|
||||
remove => connection.ActivityPaused -= value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event when the connection to the server is unpaused
|
||||
/// </summary>
|
||||
public event Action ActivityUnpaused
|
||||
{
|
||||
add => connection.ActivityUnpaused += value;
|
||||
remove => connection.ActivityUnpaused -= value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event when an exception happened
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user