示例#1
0
        private void OnAuthenticate(IAsyncResult ar)
        {
            SslStream at = ar.AsyncState as SslStream;

            try
            {
                at.EndAuthenticateAsClient(ar);
                _connected        = true;
                pendingConnection = false;
                ConnectionChangedState?.Invoke(null, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            try
            {
                BUFFER = new byte[2 << 10];
                at.BeginRead(BUFFER, 0, 2 << 10, OnRecive, at);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                OnDC();
            }
        }
示例#2
0
 protected void OnDC()
 {
     if (_connected)
     {
         ConnectionChangedState?.Invoke(null, false);
     }
     pendingConnection = false;
     _connected        = false;
     wholeMess         = new List <byte>();
     wholeSize         = 0;
 }