1
0
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:
Jan Korf 2019-02-01 17:01:02 +01:00
parent 7020b5cb14
commit d3cd128ca8
3 changed files with 16 additions and 0 deletions

View File

@ -158,6 +158,7 @@ namespace CryptoExchange.Net
catch(Exception ex)
{
log.Write(LogVerbosity.Error, $"Socket {subscription.Socket.Id} Exception during message processing\r\nProcessor: {currentHandlerName}\r\nException: {ex}\r\nData: {data}");
subscription.InvokeExceptionHandler(ex);
}
}

View File

@ -12,6 +12,7 @@ namespace CryptoExchange.Net.Sockets
{
public event Action ConnectionLost;
public event Action<TimeSpan> ConnectionRestored;
public event Action<Exception> Exception;
/// <summary>
/// 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()
{
Socket.ShouldReconnect = false;

View File

@ -25,6 +25,15 @@ namespace CryptoExchange.Net.Sockets
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>
/// The id of the socket
/// </summary>