Exemplo n.º 1
0
        /// <summary>
        /// Http servers message processor. This method reads a message from a socket and calls downstream
        /// processes that parse the request, dispatch to a method and returns a response.
        /// </summary>
        /// <remarks>The parameters should always be set to null. See IWsTransportMessageProcessor for details.</remarks>
        public void ProcessRequest()
        {
            // Process the message
            if (m_context.Message != null)
            {
                WsMessage response = ProcessRequestMessage(m_context.Message);

                m_context.Reply(response);
            }
        }
Exemplo n.º 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;
                    }
                }
            }
        }