Inheritance: XmlRpcHttpServerProtocol
Example #1
0
 LdtpdService()
 {
     if (!String.IsNullOrEmpty(ldtpDebugEnv))
         debug = true;
     if (String.IsNullOrEmpty(ldtpPort))
         ldtpPort = "4118";
     common = new Common(debug);
     windowList = new WindowList(common);
     listener = new HttpListener();
     listener.Prefixes.Add("http://localhost:" + ldtpPort + "/");
     listener.Prefixes.Add("http://+:" + ldtpPort + "/");
     // Listen on all possible IP address
     if (listenAllInterface != null && listenAllInterface.Length > 0)
     {
         if (debug)
             Console.WriteLine("Listening on all interface");
         listener.Prefixes.Add("http://*:" + ldtpPort + "/");
     }
     else
     {
         // For Windows 8, still you need to add firewall rules
         // Refer: README.txt
         if (debug)
             Console.WriteLine("Listening only on local interface");
     }
     listener.Start();
     svc = new Core(windowList, common, debug);
 }
Example #2
0
        private void ListenerCallback(HttpListenerContext fixtureContext)
        {
            var context = fixtureContext.Request.RawUrl.Replace("/", "");

            if (context.ToLower().Equals("gui"))
            {
                if (fixtureSvc == null)
                    fixtureSvc = new GoogleFixture();

                fixtureSvc.ProcessRequest(fixtureContext);
            }
        }
Example #3
0
        static void SingleThreadExec()
        {
            bool debug = false;
            string ldtpDebugEnv = Environment.GetEnvironmentVariable("LDTP_DEBUG");
            string ldtpPort = Environment.GetEnvironmentVariable("LDTP_SERVER_PORT");
            string listenAllInterface = Environment.GetEnvironmentVariable(
                "LDTP_LISTEN_ALL_INTERFACE");
            if (!String.IsNullOrEmpty(ldtpDebugEnv))
                debug = true;
            if (String.IsNullOrEmpty(ldtpPort))
                ldtpPort = "4118";
            Common common = new Common(debug);
            /*
            // If planning to use Remoting instead of HTTP
            // use this commented portion of code
            // NOTE: To have this at work, you need to add your
            // app under Firewall
            IDictionary props = new Hashtable();
            props["name"] = "LdtpdService";
            props["port"] = 4118;
            HttpChannel channel = new HttpChannel(
               props,
               null,
               new XmlRpcServerFormatterSinkProvider()
            );
            ChannelServices.RegisterChannel(channel, false);

            RemotingConfiguration.RegisterWellKnownServiceType(
              typeof(LdtpdMain),
              "service.rem",
              WellKnownObjectMode.Singleton);
            Console.WriteLine("Press <ENTER> to shutdown");
            Console.ReadLine();
            /**/
            WindowList windowList = new WindowList(common);
            HttpListener listener = new HttpListener();
            listener.Prefixes.Add("http://localhost:" + ldtpPort + "/");
            listener.Prefixes.Add("http://+:" + ldtpPort + "/");
            // Listen on all possible IP address
            if (String.IsNullOrEmpty(listenAllInterface))
            {
                if (debug)
                    Console.WriteLine("Listening on all interface");
                listener.Prefixes.Add("http://*:" + ldtpPort + "/");
            }
            else
            {
                // For Windows 8, still you need to add firewall rules
                // Refer: README.txt
                if (debug)
                    Console.WriteLine("Listening only on local interface");
            }
            listener.Start();
            XmlRpcListenerService svc = new Core(windowList, common, debug);
            try
            {
                while (true)
                {
                    GC.Collect();
                    try
                    {
                        if (debug)
                            Console.WriteLine("Waiting for clients");
                        HttpListenerContext context = listener.GetContext();
                        // Don't create LDTP instance here, this creates
                        // new object for every request !
                        // Moved before creating HttpListenerContext
                        //XmlRpcListenerService svc = new LdtpdMain();
                        if (debug)
                            Console.WriteLine("Processing request");
                        svc.ProcessRequest(context);
                        /*
                        // FIXME: If trying to do parallel process
                        // memory usage goes high and never comes back
                        // This is required for startprocessmonitor API
                        Thread parallelProcess = new Thread(delegate()
                        {
                            try
                            {
                                svc.ProcessRequest(context);
                            }
                            finally
                            {
                                context.Response.Close();
                                context = null;
                                GC.Collect();
                            }
                        });
                        parallelProcess.Start();
                        /* */
                        context.Response.Close();
                        context = null;
                    }
                    catch (InvalidOperationException ex)
                    {
                        common.LogMessage(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                common.LogMessage(ex);
            }
            finally
            {
                svc = null;
                windowList = null;
                listener.Stop();
            }
        }
Example #4
0
 public Listener(XmlRpcListenerService svc, string uri)
 {
     _svc = svc;
     _lstner.Prefixes.Add(uri);
 }
Example #5
0
 public Listener(XmlRpcListenerService svc, string uri)
 {
     _svc = svc;
     _lstner.Prefixes.Add(uri);
 }
Example #6
0
        internal void ProcessJavaRequest(object oContext)
        {
            try
            {
                if (svc == null)
                {
                    svc = new JavaThalamusEventHandler(publisher);
                }
                svc.ProcessRequest((HttpListenerContext)oContext);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }
Example #7
0
        private void ListenerCallback(HttpListenerContext fixtureContext)
        {
            var context = fixtureContext.Request.RawUrl.Replace("/", "");

            if (context.ToLower().Equals("sample"))
            {
                if (xmlRpcListenerService == null)
                    xmlRpcListenerService = new SampleFixture() { StoryContext = XmlRpcServer.StoryContext };

                xmlRpcListenerService.ProcessRequest(fixtureContext);
            }
        }
Example #8
0
 public Listener(XmlRpcListenerService svc)
 {
     _svc = svc;
       _lstner.Prefixes.Add("http://127.0.0.1:11000/");
 }