Пример #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();
        }
Пример #2
0
        public override void Shutdown()
        {
            base.Shutdown();

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