Fixed reconnection issues. Force socket client to be a base class.
This commit is contained in:
parent
ab90d47b89
commit
37493244b1
@ -27,6 +27,9 @@ namespace CommonSocketLibrary.Abstract
|
||||
_disposed = false;
|
||||
}
|
||||
|
||||
|
||||
public abstract Task Connect();
|
||||
|
||||
protected async Task ConnectAsync(string url)
|
||||
{
|
||||
if (_socket != null)
|
||||
@ -114,7 +117,7 @@ namespace CommonSocketLibrary.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task Reconnect(IBackoff backoff, Action reconnect)
|
||||
protected async Task Reconnect(IBackoff backoff)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@ -122,11 +125,11 @@ namespace CommonSocketLibrary.Abstract
|
||||
{
|
||||
TimeSpan delay = backoff.GetNextDelay();
|
||||
await Task.Delay(delay);
|
||||
reconnect.Invoke();
|
||||
await Connect();
|
||||
backoff.Reset();
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
_logger.Error("Unable to reconnect to server.");
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using Serilog;
|
||||
|
||||
namespace CommonSocketLibrary.Common
|
||||
{
|
||||
public class WebSocketClient : SocketClient<WebSocketMessage>
|
||||
public abstract class WebSocketClient : SocketClient<WebSocketMessage>
|
||||
{
|
||||
protected IDictionary<int, IWebSocketHandler> _handlers;
|
||||
private readonly MessageTypeManager<IWebSocketHandler> _messageTypeManager;
|
||||
|
Loading…
Reference in New Issue
Block a user