public async void Quit(string reason) { if (IsQuitting) { return; } IsQuitting = true; if (reason == null) { await SendRawMessage("QUIT"); } else { await SendRawMessage("QUIT :{0}", reason); } Socket.BeginDisconnect(false, ar => { Socket.EndDisconnect(ar); NetworkStream.Close(); NetworkStream.Dispose(); NetworkStream = null; Socket.Dispose(); if (OnDisconnected != null) { OnDisconnected(this, new EventArgs()); } }, null); PingTimer.Dispose(); }
public override void Shutdown() { base.Shutdown(); if (PingTimer != null) { PingTimer.Dispose(); PingTimer = null; } }
public void Quit(string reason) { if (reason == null) { SendRawMessage("QUIT"); } else { SendRawMessage("QUIT :{0}", reason); } Socket.Disconnect(false); PingTimer.Dispose(); }
public void Quit(string reason) { if (reason == null) { SendRawMessage("QUIT"); } else { SendRawMessage("QUIT :{0}", reason); } Socket.BeginDisconnect(false, ar => { Socket.EndDisconnect(ar); NetworkStream.Dispose(); NetworkStream = null; }, null); PingTimer.Dispose(); }
/// <summary> /// Send a QUIT message with a reason and disconnect. /// </summary> public async ValueTask Quit(string reason) { if (reason == null) { await SendRawMessage("QUIT"); } else { await SendRawMessage("QUIT :{0}", reason); } try { TcpClient.Close(); } catch { } TcpClient.Dispose(); TcpClient = null; StreamReader = null; try { Pipe.Writer.Complete(); } catch { } try { Pipe.Reader.Complete(); } catch { } try { RW.Writer.Complete(); } catch { } Pipe = null; PingTimer.Dispose(); }