Exemplo n.º 1
0
 private void StopServer()
 {
     if (server != null)
     {
         log.Information("Stopping Server");
         if (server.IsRunning)
         {
             server.Stop();
             log.Information("Server Stopped");
         }
         server.Dispose();
         log.Information("Server Disposed");
     }
 }
Exemplo n.º 2
0
        public void Stop()
        {
            if (_listenerServiceHost != null)
            {
                _listenerServiceHost.Dispose();
                _listenerServiceHost = null;
            }

            if (_nativeServiceHost != null)
            {
                if (_nativeServiceHost.State != CommunicationState.Faulted)
                {
                    _nativeServiceHost.BeginClose(null, null);
                }
                _nativeServiceHost = null;
            }

            if (_serviceHost != null)
            {
                if (_serviceHost.State != CommunicationState.Faulted)
                {
                    _serviceHost.BeginClose(null, null);
                }
                _serviceHost = null;
            }

            if (_service != null)
            {
                _service.Dispose();
                _service = null;
            }

            if (_remoteServer != null)
            {
                _remoteServer.Dispose();
                _remoteServer = null;
            }

            if (_server != null)
            {
                _server.Stop();
                _server = null;
            }
        }
        static void Main(string[] args)
        {
            RemoteServer rso = null;
            string       request;
            string       response;

            try
            {
                rso     = new RemoteServer();
                request = "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"subtract\" , \"params\": {\"subtrahend\": 23.4, \"minuend\": 42.8}}";
                rso.Connect("jsonrpcservertest", null, null);
                response = rso.JsonRpcRequest(request);
                Console.WriteLine("#### Response ####");
                Console.WriteLine(response);
            }
            finally
            {
                if (rso != null)
                {
                    rso.Dispose();
                }
            }
        }
Exemplo n.º 4
0
 private static void ShutdownServer()
 {
     httpServer.Dispose();
     continueRunning = false;
 }
Exemplo n.º 5
0
 private void StopServer()
 {
     Screens.Clear();
     server.Dispose();
     server = null;
 }
Exemplo n.º 6
0
        private void RunTestCodeWithServerAndClientConnection(TestCodeDelegate deleg)
        {
            var mouse = new RemoteMouse();
            var touch = new RemoteTouch();
            var keyboard = new RemoteKeyboard();
            var analyser = new InputPacketsAnalyser();
            analyser.SetActiveMouse(mouse);
            analyser.SetActiveTouch(touch);
            analyser.SetActiveKeyboard(keyboard);
            var server = new RemoteServer(analyser, TestPort);
            RemoteClient client = CreateTestClient();
            Task connection = client.ConnectToServerAsync();
            connection.Wait();

            var data = new TestObjects
            { Client = client, Mouse = mouse, Touch = touch, Keyboard = keyboard };
            server.Received += delegate
            {
                data.NumberOfReceivedMessages++;
            };

            try
            {
                if (deleg != null)
                    deleg(data);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
            finally
            {
                client.Dispose();
                server.Dispose();
            }
        }