1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-11 16:32:57 +00:00

Added reset to base socket to create a new socket when trying to reconnect

This commit is contained in:
JKorf
2018-12-17 11:08:03 +01:00
parent d7600b5495
commit 56da39b595
4 changed files with 13 additions and 0 deletions
@@ -58,6 +58,10 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
throw new Exception("Socket not connected");
}
public void Reset()
{
}
public Task Close()
{
Connected = false;
@@ -26,6 +26,7 @@ namespace CryptoExchange.Net.Interfaces
TimeSpan Timeout { get; set; }
Task<bool> Connect();
void Send(string data);
void Reset();
Task Close();
void SetProxy(string host, int port);
}
+2
View File
@@ -173,6 +173,8 @@ namespace CryptoExchange.Net
Task.Run(() =>
{
Thread.Sleep(ReconnectInterval);
socket.Reset();
if (!socket.Connect().Result)
{
log.Write(LogVerbosity.Debug, $"Socket {socket.Id} failed to reconnect");
+6
View File
@@ -163,6 +163,12 @@ namespace CryptoExchange.Net.Sockets
}).ConfigureAwait(false);
}
public virtual void Reset()
{
socket.Dispose();
socket = null;
}
public virtual void Send(string data)
{
socket.Send(data);