mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-04-12 12:06:29 +00:00
Pull request and build
This commit is contained in:
commit
cb63734fba
3 changed files with 23 additions and 12 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -193,13 +193,9 @@ namespace PepperDash.Core
|
|||
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
|
||||
{
|
||||
if (programEventType == eProgramStatusEventType.Stopping)
|
||||
{
|
||||
if (Client != null)
|
||||
{
|
||||
Debug.Console(1, this, "Program stopping. Closing connection");
|
||||
Client.DisconnectFromServer();
|
||||
Client.Dispose();
|
||||
}
|
||||
DisconnectClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +214,7 @@ namespace PepperDash.Core
|
|||
public void Connect()
|
||||
{
|
||||
if (IsConnected)
|
||||
return;
|
||||
DisconnectClient();
|
||||
|
||||
if (string.IsNullOrEmpty(Hostname))
|
||||
{
|
||||
|
|
@ -233,8 +229,11 @@ namespace PepperDash.Core
|
|||
}
|
||||
}
|
||||
|
||||
if (Client == null)
|
||||
{
|
||||
Client = new TCPClient(Hostname, Port, BufferSize);
|
||||
Client.SocketStatusChange += Client_SocketStatusChange;
|
||||
}
|
||||
|
||||
Client.ConnectToServerAsync(null);
|
||||
DisconnectCalledByUser = false;
|
||||
|
|
@ -243,7 +242,18 @@ namespace PepperDash.Core
|
|||
public void Disconnect()
|
||||
{
|
||||
DisconnectCalledByUser = true;
|
||||
DisconnectClient();
|
||||
}
|
||||
|
||||
public void DisconnectClient()
|
||||
{
|
||||
if (Client != null)
|
||||
{
|
||||
Debug.Console(1, this, "Disconnecting client");
|
||||
//Client.SocketStatusChange -= Client_SocketStatusChange;
|
||||
if(IsConnected)
|
||||
Client.DisconnectFromServer();
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectToServerCallback(TCPClient c)
|
||||
|
|
@ -254,7 +264,8 @@ namespace PepperDash.Core
|
|||
|
||||
void WaitAndTryReconnect()
|
||||
{
|
||||
Client.DisconnectFromServer();
|
||||
DisconnectClient();
|
||||
|
||||
Debug.Console(2, "Attempting reconnect, status={0}", Client.ClientStatus);
|
||||
if(!DisconnectCalledByUser)
|
||||
RetryTimer = new CTimer(o => { Client.ConnectToServerAsync(ConnectToServerCallback); }, AutoReconnectIntervalMs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue