コード例 #1
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            while (m_isStarted)
            {
                try
                {
                    _Bind.RequestContext context = m_replyChannel.ReceiveRequest();

                    // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                    if (context != null)
                    {
                        WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints);

                        // Try to get a processing thread and process the request
                        m_threadManager.StartNewThread(processor, context);
                        m_ctx.ContextObject = context.m_context.ContextObject;
                    }
                }
                catch
                {
                    m_ctx.ContextObject = null;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// HttpServer Socket Listener
        /// </summary>
        public void Listen()
        {
            // Create listener and start listening
            while (m_isStarted)
            {
                try
                {
                    _Bind.RequestContext context = m_replyChannel.ReceiveRequest();

                    // The context returned by m_httpListener.GetContext(); can be null in case the service was stopped.
                    if (context != null)
                    {
                        WsHttpMessageProcessor processor = new WsHttpMessageProcessor(m_serviceEndpoints, context);

                        if (m_threadManager.ThreadsAvailable == false)
                        {
                            WsWsaHeader header = new WsWsaHeader();

                            context.Reply(WsFault.GenerateFaultResponse(header, WsFaultType.WsaEndpointUnavailable, "Service Unavailable (busy)", context.Version));

                            System.Ext.Console.Write("Http max thread count exceeded. Request ignored.");
                        }
                        else
                        {
                            // Try to get a processing thread and process the request
                            m_threadManager.StartNewThread(processor);
                        }
                    }
                }
                catch
                {
                    if (!m_isStarted)
                    {
                        break;
                    }
                }
            }
        }