mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 16:36:15 +00:00
Added reset to base socket to create a new socket when trying to reconnect
This commit is contained in:
parent
d7600b5495
commit
56da39b595
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user