mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 16:36:15 +00:00
Added exception event on socket subscription
This commit is contained in:
parent
7020b5cb14
commit
d3cd128ca8
@ -158,6 +158,7 @@ namespace CryptoExchange.Net
|
|||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
log.Write(LogVerbosity.Error, $"Socket {subscription.Socket.Id} Exception during message processing\r\nProcessor: {currentHandlerName}\r\nException: {ex}\r\nData: {data}");
|
log.Write(LogVerbosity.Error, $"Socket {subscription.Socket.Id} Exception during message processing\r\nProcessor: {currentHandlerName}\r\nException: {ex}\r\nData: {data}");
|
||||||
|
subscription.InvokeExceptionHandler(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
{
|
{
|
||||||
public event Action ConnectionLost;
|
public event Action ConnectionLost;
|
||||||
public event Action<TimeSpan> ConnectionRestored;
|
public event Action<TimeSpan> ConnectionRestored;
|
||||||
|
public event Action<Exception> Exception;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Message handlers for this subscription. Should return true if the message is handled and should not be distributed to the other handlers
|
/// Message handlers for this subscription. Should return true if the message is handled and should not be distributed to the other handlers
|
||||||
@ -145,6 +146,11 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InvokeExceptionHandler(Exception e)
|
||||||
|
{
|
||||||
|
Exception(e);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task Close()
|
public async Task Close()
|
||||||
{
|
{
|
||||||
Socket.ShouldReconnect = false;
|
Socket.ShouldReconnect = false;
|
||||||
|
@ -25,6 +25,15 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
remove => subscription.ConnectionRestored -= value;
|
remove => subscription.ConnectionRestored -= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event when an exception happened
|
||||||
|
/// </summary>
|
||||||
|
public event Action<Exception> Exception
|
||||||
|
{
|
||||||
|
add => subscription.Exception += value;
|
||||||
|
remove => subscription.Exception -= value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The id of the socket
|
/// The id of the socket
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user