示例#1
0
        public static HttpListenerWrapper GetWrapper(int port, List <string> nsNames)
        {
            string webFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\Web";

            myCore.Logging.log("Trying to start wrapper on folder : " + webFolder, 1, myCore.LogType.Information);

            HttpListenerWrapper lw = (HttpListenerWrapper)ApplicationHost.CreateApplicationHost(typeof(HttpListenerWrapper), "/", webFolder);

            List <string> prefixes = new List <string>();

            if (nsNames != null)
            {
                foreach (string nsName in nsNames)
                {
                    prefixes.Add("http://" + nsName + ":" + port.ToString() + "/QvExtApi/");
                }
            }

            HttpListenerWrapper.addPrefix(prefixes, "http://localhost:" + port.ToString() + "/QvExtApi/");
            HttpListenerWrapper.addPrefix(prefixes, "http://127.0.0.1:" + port.ToString() + "/QvExtApi/");

            lw.Configure(prefixes.ToArray(), "/", webFolder);

            return(lw);
        }
示例#2
0
        public void start()
        {
            myCore.Logging.log("Webserver starting ...", 0, myCore.LogType.Information);

            int           port    = Convert.ToInt32(conf["port"]);
            List <string> nsNames = new List <string> ()
            {
                conf["nsName"]
            };

            myWeb.HttpListenerWrapper lw = myWeb.HttpListenerWrapper.GetWrapper(port, nsNames);
            lw.Start();

            myCore.Logging.log("Listening for requests on port {0} on localhost, 127.0.0.1{1} ...", 1, myCore.LogType.Information, port, ((nsNames != null && nsNames.Count > 0) ? ", " + String.Join(", ", nsNames.ToArray()) : ""));

            this.WSHostWorkerObject = new myWeb.HostWorker();
            this.WSHostWorkerThread = new Thread(this.WSHostWorkerObject.DoWork);

            this.WSHostWorkerThread.Start(lw);
        }