예제 #1
0
파일: Program.cs 프로젝트: Mokarski/Vagonka
        internal static void RpcTest(ILog logger)
        {
            var loop = true;

            //var modem = new GsmModem(logger);
            //modem.Start();

            var proxy = new ProxyService(logger);

            proxy.Start();


            var server = new ControllerServer(logger, 3302);

            server.Start();



            proxy.AddService(new LocalRpcService());
            proxy.AddService(new IdentificationService());

            var plugin = new Plugin();

            plugin.AddService(new RemoteRpcService());
            plugin.Register("Dummy");


            plugin.Invoke("local.dummy.time");

            /*
             * proxy.Invoke(new JsonRequest(0, "local.dummy.time", null));
             * proxy.Invoke(new JsonRequest(0, "remote.dummy.time", null));
             *
             * proxy.Invoke(new JsonRequest("{\"id\":\"12345\",\"method\":\"smart.relay\",\"params\":{\"relayId\":0, \"feederId\":2, \"state\":true}}"));
             */

            var clientListner = new ServerConnection(logger, proxy, "127.0.0.1", 3300)
            {
                ReconnectionTimeout = new TimeSpan(0, 0, 5)
            };                                                                                                                        //, RequestGuardtime = new TimeSpan(0, 1, 0)};

            //var clientListner = new ServerConnection(logger, proxy, "92.63.81.70", 3300) { ReconnectionTimeout = new TimeSpan(0, 0, 5) };//, RequestGuardtime = new TimeSpan(0, 1, 0)};
            clientListner.Start();

            while (loop)
            {
                try
                {
                    // TODO
                    //server.Invoke("111", new JsonRequest(0, "local.dummy.time", null));

                    //Thread.Sleep(100);
                }
                catch (ThreadAbortException)
                {
                    server.Stop();

                    throw;
                }
                catch (Exception ex)
                {
                    if (!(ex is SocketException || ex is IOException || ex is InvalidOperationException))
                    {
                        logger.Warn("Unexpected exception " + ex.GetType() + " at ModuleThread " + ex.Message);
                    }
                }
            }

            plugin.Unregister();

            loop = true;
            while (loop)
            {
                // TODO
                //proxy.Invoke(new JsonRequest(0, "remote.dummy.time", null));
                Thread.Sleep(1000);
            }

            clientListner.Stop();
            proxy.Stop();
            proxy.Dispose();
            //modem.Stop();
        }
 public void TestCleanup()
 {
     _loadTestingWorkflowPluginContext.PostTestCleanup();
     Driver.Close();
     _proxyService.Dispose();
 }