GetContext() private method

private GetContext ( ) : WebSocketSharp.Net.HttpListenerContext
return WebSocketSharp.Net.HttpListenerContext
コード例 #1
0
ファイル: ListenerAsyncResult.cs プロジェクト: yankaics/cms-1
        internal HttpListenerContext GetContext()
        {
            if (forward != null)
            {
                return(forward.GetContext());
            }
            if (exception != null)
            {
                throw exception;
            }

            return(context);
        }
コード例 #2
0
        public HttpListenerContext EndGetContext(IAsyncResult asyncResult)
        {
            this.CheckDisposed();
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            ListenerAsyncResult listenerAsyncResult = asyncResult as ListenerAsyncResult;

            if (listenerAsyncResult == null)
            {
                throw new ArgumentException("Wrong IAsyncResult.", "asyncResult");
            }
            if (listenerAsyncResult.EndCalled)
            {
                throw new InvalidOperationException("Cannot reuse this IAsyncResult.");
            }
            listenerAsyncResult.EndCalled = true;
            if (!listenerAsyncResult.IsCompleted)
            {
                listenerAsyncResult.AsyncWaitHandle.WaitOne();
            }
            object syncRoot = ((ICollection)this._waitQueue).SyncRoot;

            lock (syncRoot)
            {
                int num = this._waitQueue.IndexOf(listenerAsyncResult);
                if (num >= 0)
                {
                    this._waitQueue.RemoveAt(num);
                }
            }
            HttpListenerContext   context = listenerAsyncResult.GetContext();
            AuthenticationSchemes authenticationSchemes = this.SelectAuthenticationScheme(context);

            if (authenticationSchemes != AuthenticationSchemes.Anonymous)
            {
                context.SetUser(authenticationSchemes, this.Realm, this.UserCredentialsFinder);
            }
            return(context);
        }
コード例 #3
0
        /// <summary>
        /// Ends an asynchronous operation to get an incoming request information.
        /// </summary>
        /// <remarks>
        /// This method completes an asynchronous operation started by calling the <see cref="BeginGetContext"/> method.
        /// </remarks>
        /// <returns>
        /// A <see cref="HttpListenerContext"/> that contains a client's request information.
        /// </returns>
        /// <param name="asyncResult">
        /// An <see cref="IAsyncResult"/> obtained by calling the <see cref="BeginGetContext"/> method.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="asyncResult"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="asyncResult"/> was not obtained by calling the <see cref="BeginGetContext"/> method.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The EndGetContext method was already called for the specified <paramref name="asyncResult"/>.
        /// </exception>
        public HttpListenerContext EndGetContext(IAsyncResult asyncResult)
        {
            CheckDisposed();
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

            ListenerAsyncResult ares = asyncResult as ListenerAsyncResult;

            if (ares == null)
            {
                throw new ArgumentException("Wrong IAsyncResult.", "asyncResult");
            }

            if (ares.EndCalled)
            {
                throw new InvalidOperationException("Cannot reuse this IAsyncResult.");
            }
            ares.EndCalled = true;

            if (!ares.IsCompleted)
            {
                ares.AsyncWaitHandle.WaitOne();
            }

            lock (((ICollection)wait_queue).SyncRoot) {
                int idx = wait_queue.IndexOf(ares);
                if (idx >= 0)
                {
                    wait_queue.RemoveAt(idx);
                }
            }

            HttpListenerContext context = ares.GetContext();

            context.ParseAuthentication(SelectAuthenticationScheme(context));
            return(context);            // This will throw on error.
        }