mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 21:24:43 +00:00
Pull request and build
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -194,12 +194,8 @@ namespace PepperDash.Core
|
|||||||
{
|
{
|
||||||
if (programEventType == eProgramStatusEventType.Stopping)
|
if (programEventType == eProgramStatusEventType.Stopping)
|
||||||
{
|
{
|
||||||
if (Client != null)
|
Debug.Console(1, this, "Program stopping. Closing connection");
|
||||||
{
|
DisconnectClient();
|
||||||
Debug.Console(1, this, "Program stopping. Closing connection");
|
|
||||||
Client.DisconnectFromServer();
|
|
||||||
Client.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +213,8 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
public void Connect()
|
public void Connect()
|
||||||
{
|
{
|
||||||
if (IsConnected)
|
if (IsConnected)
|
||||||
return;
|
DisconnectClient();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Hostname))
|
if (string.IsNullOrEmpty(Hostname))
|
||||||
{
|
{
|
||||||
@@ -233,8 +229,11 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client = new TCPClient(Hostname, Port, BufferSize);
|
if (Client == null)
|
||||||
Client.SocketStatusChange += Client_SocketStatusChange;
|
{
|
||||||
|
Client = new TCPClient(Hostname, Port, BufferSize);
|
||||||
|
Client.SocketStatusChange += Client_SocketStatusChange;
|
||||||
|
}
|
||||||
|
|
||||||
Client.ConnectToServerAsync(null);
|
Client.ConnectToServerAsync(null);
|
||||||
DisconnectCalledByUser = false;
|
DisconnectCalledByUser = false;
|
||||||
@@ -243,9 +242,20 @@ namespace PepperDash.Core
|
|||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
DisconnectCalledByUser = true;
|
DisconnectCalledByUser = true;
|
||||||
Client.DisconnectFromServer();
|
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)
|
void ConnectToServerCallback(TCPClient c)
|
||||||
{
|
{
|
||||||
if (c.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED)
|
if (c.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED)
|
||||||
@@ -254,7 +264,8 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
void WaitAndTryReconnect()
|
void WaitAndTryReconnect()
|
||||||
{
|
{
|
||||||
Client.DisconnectFromServer();
|
DisconnectClient();
|
||||||
|
|
||||||
Debug.Console(2, "Attempting reconnect, status={0}", Client.ClientStatus);
|
Debug.Console(2, "Attempting reconnect, status={0}", Client.ClientStatus);
|
||||||
if(!DisconnectCalledByUser)
|
if(!DisconnectCalledByUser)
|
||||||
RetryTimer = new CTimer(o => { Client.ConnectToServerAsync(ConnectToServerCallback); }, AutoReconnectIntervalMs);
|
RetryTimer = new CTimer(o => { Client.ConnectToServerAsync(ConnectToServerCallback); }, AutoReconnectIntervalMs);
|
||||||
|
|||||||
Reference in New Issue
Block a user