mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-18 06:04:44 +00:00
Reworks reconnect timer due to issues seen on 4 series where autoreconnect cycle breaks.
This commit is contained in:
@@ -151,6 +151,11 @@ namespace PepperDash.Core
|
|||||||
Username = username;
|
Username = username;
|
||||||
Password = password;
|
Password = password;
|
||||||
AutoReconnectIntervalMs = 5000;
|
AutoReconnectIntervalMs = 5000;
|
||||||
|
|
||||||
|
ReconnectTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
Connect();
|
||||||
|
}, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -162,6 +167,11 @@ namespace PepperDash.Core
|
|||||||
StreamDebugging = new CommunicationStreamDebugging(SPlusKey);
|
StreamDebugging = new CommunicationStreamDebugging(SPlusKey);
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||||
AutoReconnectIntervalMs = 5000;
|
AutoReconnectIntervalMs = 5000;
|
||||||
|
|
||||||
|
ReconnectTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
Connect();
|
||||||
|
}, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -203,11 +213,7 @@ namespace PepperDash.Core
|
|||||||
Debug.Console(1, this, "attempting connect");
|
Debug.Console(1, this, "attempting connect");
|
||||||
|
|
||||||
// Cancel reconnect if running.
|
// Cancel reconnect if running.
|
||||||
if (ReconnectTimer != null)
|
ReconnectTimer.Stop();
|
||||||
{
|
|
||||||
ReconnectTimer.Stop();
|
|
||||||
ReconnectTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't try to connect if already
|
// Don't try to connect if already
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
@@ -297,11 +303,7 @@ namespace PepperDash.Core
|
|||||||
{
|
{
|
||||||
ConnectEnabled = false;
|
ConnectEnabled = false;
|
||||||
// Stop trying reconnects, if we are
|
// Stop trying reconnects, if we are
|
||||||
if (ReconnectTimer != null)
|
ReconnectTimer.Stop();
|
||||||
{
|
|
||||||
ReconnectTimer.Stop();
|
|
||||||
ReconnectTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
||||||
}
|
}
|
||||||
@@ -334,20 +336,9 @@ namespace PepperDash.Core
|
|||||||
if (AutoReconnect && ConnectEnabled)
|
if (AutoReconnect && ConnectEnabled)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
Debug.Console(1, this, "Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||||
if (ReconnectTimer == null)
|
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
||||||
{
|
Debug.Console(1, this, "Attempting connection in {0} seconds",
|
||||||
ReconnectTimer = new CTimer(o =>
|
(float) (AutoReconnectIntervalMs/1000));
|
||||||
{
|
|
||||||
Connect();
|
|
||||||
}, AutoReconnectIntervalMs);
|
|
||||||
Debug.Console(1, this, "Attempting connection in {0} seconds",
|
|
||||||
(float) (AutoReconnectIntervalMs/1000));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Console(1, this, "{0} second reconnect cycle running",
|
|
||||||
(float) (AutoReconnectIntervalMs/1000));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,16 @@ namespace PepperDash.Core
|
|||||||
BufferSize = bufferSize;
|
BufferSize = bufferSize;
|
||||||
AutoReconnectIntervalMs = 5000;
|
AutoReconnectIntervalMs = 5000;
|
||||||
|
|
||||||
|
RetryTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
if (Client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client.ConnectToServerAsync(ConnectToServerCallback);
|
||||||
|
}, Timeout.Infinite);
|
||||||
|
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,6 +209,16 @@ namespace PepperDash.Core
|
|||||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||||
AutoReconnectIntervalMs = 5000;
|
AutoReconnectIntervalMs = 5000;
|
||||||
BufferSize = 2000;
|
BufferSize = 2000;
|
||||||
|
|
||||||
|
RetryTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
if (Client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client.ConnectToServerAsync(ConnectToServerCallback);
|
||||||
|
}, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -211,6 +231,16 @@ namespace PepperDash.Core
|
|||||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||||
AutoReconnectIntervalMs = 5000;
|
AutoReconnectIntervalMs = 5000;
|
||||||
BufferSize = 2000;
|
BufferSize = 2000;
|
||||||
|
|
||||||
|
RetryTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
if (Client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client.ConnectToServerAsync(ConnectToServerCallback);
|
||||||
|
}, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -287,11 +317,7 @@ namespace PepperDash.Core
|
|||||||
DisconnectCalledByUser = true;
|
DisconnectCalledByUser = true;
|
||||||
|
|
||||||
// Stop trying reconnects, if we are
|
// Stop trying reconnects, if we are
|
||||||
if (RetryTimer != null)
|
RetryTimer.Stop();
|
||||||
{
|
|
||||||
RetryTimer.Stop();
|
|
||||||
RetryTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Client != null)
|
if (Client != null)
|
||||||
{
|
{
|
||||||
@@ -337,15 +363,7 @@ namespace PepperDash.Core
|
|||||||
Debug.Console(1, this, "Attempting reconnect, status={0}", Client.ClientStatus);
|
Debug.Console(1, this, "Attempting reconnect, status={0}", Client.ClientStatus);
|
||||||
|
|
||||||
if (!DisconnectCalledByUser)
|
if (!DisconnectCalledByUser)
|
||||||
RetryTimer = new CTimer(o =>
|
RetryTimer.Reset(AutoReconnectIntervalMs);
|
||||||
{
|
|
||||||
if (Client == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Client.ConnectToServerAsync(ConnectToServerCallback);
|
|
||||||
}, AutoReconnectIntervalMs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -382,10 +400,7 @@ namespace PepperDash.Core
|
|||||||
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
|
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.ReceiveDataAsync(Receive);
|
client.ReceiveDataAsync(Receive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user