Пример #1
0
        private bool authenticateClient(TcpListenerWebSocketContext context)
        {
            if (_authSchemes == AuthenticationSchemes.Anonymous)
            {
                return(true);
            }

            if (_authSchemes == AuthenticationSchemes.None)
            {
                return(false);
            }

            return(context.Authenticate(_authSchemes, _realmInUse, _userCredFinder));
        }
 private void receiveRequest()
 {
     while (true)
     {
         try
         {
             TcpClient tcpClient = this._listener.AcceptTcpClient();
             ThreadPool.QueueUserWorkItem((object state) => {
                 try
                 {
                     TcpListenerWebSocketContext webSocketContext = tcpClient.GetWebSocketContext(null, this._secure, this._sslConfig, this._logger);
                     if (webSocketContext.Authenticate(this._authSchemes, this.getRealm(), this._userCredFinder))
                     {
                         this.processRequest(webSocketContext);
                     }
                 }
                 catch (Exception exception)
                 {
                     this._logger.Fatal(exception.ToString());
                     tcpClient.Close();
                 }
             });
         }
         catch (SocketException socketException1)
         {
             SocketException socketException = socketException1;
             this._logger.Warn(string.Concat("Receiving has been stopped.\n  reason: ", socketException.Message));
             break;
         }
         catch (Exception exception1)
         {
             this._logger.Fatal(exception1.ToString());
             break;
         }
     }
     if (this.IsListening)
     {
         this.abort();
     }
 }