Exemple #1
0
        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();
        }
Exemple #2
0
        public override void Shutdown()
        {
            base.Shutdown();

            if (PingTimer != null)
            {
                PingTimer.Dispose();
                PingTimer = null;
            }
        }
Exemple #3
0
 public void Quit(string reason)
 {
     if (reason == null)
     {
         SendRawMessage("QUIT");
     }
     else
     {
         SendRawMessage("QUIT :{0}", reason);
     }
     Socket.Disconnect(false);
     PingTimer.Dispose();
 }
Exemple #4
0
 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();
 }
Exemple #5
0
        /// <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();
        }