Beispiel #1
0
        public static bool InitServerB(string address)
        {
            try
            {
                if (pacPort != Global.pacPort)
                {
                    if (serverB != null)
                    {
                        serverB.Stop();
                        serverB = null;
                    }

                    if (serverB == null)
                    {
                        serverB = new HttpWebServerB(Global.pacPort, SendResponse);
                        //pacPort = Global.pacPort;
                    }
                }
                Utils.SaveLog("WebserverB at " + address);
            }
            catch (Exception ex)
            {
                Utils.SaveLog("WebserverB InitServer " + ex.Message);
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public static void InitServer(string address)
        {
            try
            {
                //pac = GetPacList(address);

                if (pacPort != Global.pacPort)
                {
                    if (server != null)
                    {
                        server.Stop();
                        server = null;
                    }

                    if (server == null)
                    {
                        server = new HttpWebServerB(Global.pacPort, SendResponse);
                        //server = new HttpWebServerC(Global.pacPort, pac);
                        pacPort = Global.pacPort;
                    }
                }

                //thread = new Thread(server.WorkThread);
                //thread.IsBackground = true;
                //thread.Start();
                Utils.SaveLog("Webserver at " + address);
            }
            catch (Exception ex)
            {
                Utils.SaveLog("Webserver InitServer " + ex.Message);
            }

            //    if (!pacList.ContainsKey(address))
            //    {
            //        pacList.Add(address, GetPacList(address));
            //    }

            //    string prefixes = string.Format("http://{0}:{1}/pac/", address, Global.pacPort);
            //    Utils.SaveLog("Webserver prefixes " + prefixes);

            //    HttpWebServer ws = new HttpWebServer(SendResponse, prefixes);
            //    ws.Run();

            //    if (!httpWebServer.ContainsKey(address) && ws != null)
            //    {
            //        httpWebServer.Add(address, ws);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    Utils.SaveLog("Webserver InitServer " + ex.Message);
            //}
        }
Beispiel #3
0
        public static void Init(Config config)
        {
            var serverB = new HttpWebServerB(Global.pacPort, SendResponse);

            pacPort = Global.pacPort;

            //if (InitServer("*"))
            //{
            //    pacPort = Global.pacPort;
            //}
            //else if (InitServer("127.0.0.1"))
            //{
            //    pacPort = Global.pacPort;
            //}
            //else
            //{
            //    Utils.SaveLog("Webserver init failed ");
            //    pacPort = 0;
            //}
        }
Beispiel #4
0
        public static void Stop()
        {
            try
            {
                if (server != null)
                {
                    server.Stop();
                    server = null;
                }
                if (serverB != null)
                {
                    serverB.Stop();
                    serverB = null;
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog("Webserver Stop " + ex.Message);
            }

            //try
            //{
            //    if (httpWebServer == null)
            //    {
            //        return;
            //    }
            //    foreach (var key in httpWebServer.Keys)
            //    {
            //        Utils.SaveLog("Webserver Stop " + key.ToString());
            //        ((HttpWebServer)httpWebServer[key]).Stop();
            //    }
            //    httpWebServer.Clear();
            //}
            //catch (Exception ex)
            //{
            //    Utils.SaveLog("Webserver Stop " + ex.Message);
            //}
        }