mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-15 20:54:46 +00:00
Merge pull request #96 from PepperDash/hotfix/tcp-client-disconnect-timer-exeption
Hotfix/tcp client disconnect timer exeption
This commit is contained in:
@@ -284,9 +284,17 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
|
DisconnectCalledByUser = true;
|
||||||
|
|
||||||
|
// Stop trying reconnects, if we are
|
||||||
|
if (RetryTimer != null)
|
||||||
|
{
|
||||||
|
RetryTimer.Stop();
|
||||||
|
RetryTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (Client != null)
|
if (Client != null)
|
||||||
{
|
{
|
||||||
DisconnectCalledByUser = true;
|
|
||||||
DisconnectClient();
|
DisconnectClient();
|
||||||
Client = null;
|
Client = null;
|
||||||
Debug.Console(1, this, "Disconnected");
|
Debug.Console(1, this, "Disconnected");
|
||||||
@@ -329,7 +337,15 @@ 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 => { Client.ConnectToServerAsync(ConnectToServerCallback); }, AutoReconnectIntervalMs);
|
RetryTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
if (Client == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client.ConnectToServerAsync(ConnectToServerCallback);
|
||||||
|
}, AutoReconnectIntervalMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user