mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 13:14:49 +00:00
Revert "Feature/ssh dispose"
This commit is contained in:
@@ -312,17 +312,15 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
try
|
ConnectEnabled = false;
|
||||||
{
|
// Stop trying reconnects, if we are
|
||||||
connectLock.Enter();
|
if (ReconnectTimer != null)
|
||||||
// Stop trying reconnects, if we are
|
{
|
||||||
ReconnectTimer.Stop();
|
ReconnectTimer.Stop();
|
||||||
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
ReconnectTimer = null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
||||||
connectLock.Leave();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -331,24 +329,45 @@ namespace PepperDash.Core
|
|||||||
private void KillClient(SocketStatus status)
|
private void KillClient(SocketStatus status)
|
||||||
{
|
{
|
||||||
KillStream();
|
KillStream();
|
||||||
|
|
||||||
if (Client != null)
|
if (Client != null)
|
||||||
{
|
{
|
||||||
try
|
IsConnecting = false;
|
||||||
{
|
Client.Disconnect();
|
||||||
Client.Disconnect();
|
Client = null;
|
||||||
Client.Dispose();
|
ClientStatus = status;
|
||||||
Client = null;
|
Debug.Console(1, this, "Disconnected");
|
||||||
ClientStatus = status;
|
|
||||||
Debug.Console(1, this, "Disconnected client");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.Console(1, this, "Exception killing client: {0}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Anything to do with reestablishing connection on failures
|
||||||
|
/// </summary>
|
||||||
|
void HandleConnectionFailure()
|
||||||
|
{
|
||||||
|
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||||
|
|
||||||
|
Debug.Console(1, this, "Client nulled due to connection failure. AutoReconnect: {0}, ConnectEnabled: {1}", AutoReconnect, ConnectEnabled);
|
||||||
|
if (AutoReconnect && ConnectEnabled)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||||
|
if (ReconnectTimer == null)
|
||||||
|
{
|
||||||
|
ReconnectTimer = new CTimer(o =>
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kills the stream
|
/// Kills the stream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user