/// <inheritdoc /> protected override void HandleDisconnect(HazelException e = null) { bool invoke = false; lock (socketLock) { //Only invoke the disconnected event if we're not already disconnecting if (State == ConnectionState.Connected) { State = ConnectionState.Disconnecting; invoke = true; } } //Invoke event outide lock if need be if (invoke) { InvokeDisconnected(e); Dispose(); } }
/// <summary> /// Called when the socket has been disconnected at the remote host. /// </summary> /// <param name="e">The exception if one was the cause.</param> protected abstract void HandleDisconnect(HazelException e = null);