Beispiel #1
0
        public void Start()
        {
            MainConsole.Instance.InfoFormat(
                "[BASE HTTP SERVER]: Starting {0} server on port {1}", Secure ? "HTTPS" : "HTTP", Port);

            try
            {
                //m_httpListener = new HttpListener();

                NotSocketErrors  = 0;
                m_internalServer = new HttpListenerManager(m_threadCount, Secure);
                if (OnOverrideRequest != null)
                {
                    m_internalServer.ProcessRequest += OnOverrideRequest;
                }
                else
                {
                    m_internalServer.ProcessRequest += OnRequest;
                }

                m_internalServer.Start(m_port);

                // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
                m_PollServiceManager = new PollServiceRequestManager(3, 25000);
                m_PollServiceManager.Start();
                HTTPDRunning = true;
            }
            catch (Exception e)
            {
                if (e is HttpListenerException && ((HttpListenerException)e).Message == "Access is denied")
                {
                    MainConsole.Instance.Error("[BASE HTTP SERVER]: You must run this program as an administrator.");
                }
                else
                {
                    MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message);
                    MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " +
                                               m_port + "?");
                }

                // We want this exception to halt the entire server since in current configurations we aren't too
                // useful without inbound HTTP.
                throw e;
            }
        }
        public void Start()
        {
            MainConsole.Instance.InfoFormat(
                "[BASE HTTP SERVER]: Starting {0} server on port {1}", Secure ? "HTTPS" : "HTTP", Port);

            try
            {
                //m_httpListener = new HttpListener();

                NotSocketErrors = 0;
                m_internalServer = new HttpListenerManager(m_threadCount, Secure);
                if (OnOverrideRequest != null)
                    m_internalServer.ProcessRequest += OnOverrideRequest;
                else
                    m_internalServer.ProcessRequest += OnRequest;

                m_internalServer.Start(m_port);

                // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
                m_PollServiceManager = new PollServiceRequestManager(3, 25000);
                m_PollServiceManager.Start();
                HTTPDRunning = true;
            }
            catch (Exception e)
            {
                if (e is HttpListenerException && ((HttpListenerException) e).Message == "Access is denied")
                    MainConsole.Instance.Error("[BASE HTTP SERVER]: You must run this program as an administrator.");
                else
                {
                    MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message);
                    MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " +
                                               m_port + "?");
                }

                // We want this exception to halt the entire server since in current configurations we aren't too
                // useful without inbound HTTP.
                throw e;
            }
        }