public void Disconnect()
{
DiagnosticAbstraction.Log(string.Format("{0} Disconnecting client", DateTime.Now.Ticks));
CheckDisposed();
OnDisconnecting();
// stop sending keep-alive messages before we close the
// session
StopKeepAliveTimer();
// disconnect and dispose the SSH session
if (Session != null)
{
// a new session is created in Connect(), so we should dispose and
// dereference the current session here
Session.ErrorOccured -= Session_ErrorOccured;
Session.HostKeyReceived -= Session_HostKeyReceived;
Session.Dispose();
Session = null;
}
OnDisconnected();
}