示例#1
0
        static void Main(string[] args)
        {
            var process = Process.Start("server.exe");

            // Register the echo service
            ServiceLocator serviceLocator = new ServiceLocator();

            serviceLocator.RegisterService("echoService", "pipe://testEchoService");

            // Create the echo service proxy
            var serviceFactory = new ServiceInterfaceFactory(serviceLocator, new PipeChannelFactory());
            var echoService    = serviceFactory.CreateServiceInterface("echoService");

            // Send some messages
            var request = Message.CreateRequest("echo");

            for (int i = 0; i < 10; i++)
            {
                request.Params = $"This is message number {i}";
                Log.Debug($"sending: {request.Params.ToString()}");
                echoService.Request(request, (r) => Log.Debug($"received: {r.Result}"), null);
            }

            // Tell the service to exit
            echoService.Request(Message.CreateRequest("exit"), null, null);
        }
示例#2
0
        private void CreateRemoteService()
        {
            this.pipeChannelFactory?.Dispose();
            this.pipeChannelFactory = new PipeChannelFactory();
            Mock <IServiceLocator> serviceLocator = new Mock <IServiceLocator>();

            serviceLocator.Setup(m => m.GetServiceUrl("TestService")).Returns("pipe://F77DE1FB-F58D-433A-B626-889FC77D096B/TestService");

            ServiceInterfaceFactory factory = new ServiceInterfaceFactory(serviceLocator.Object, this.pipeChannelFactory);

            this.remoteService = factory.CreateServiceInterface("TestService");
        }
        public void TestInitialize()
        {
            Mock <IServiceLocator> serviceLocator = new Mock <IServiceLocator>();

            serviceLocator.Setup(m => m.GetServiceUrl("TestService")).Returns("pipe://testUrl/TestService");

            this.messenger = new MessengerMock();

            Mock <IMessengerFactory> messengerFactory = new Mock <IMessengerFactory>();

            messengerFactory.Setup(m => m.GetMessenger(It.IsAny <string>())).Returns(this.messenger);
            this.serviceFactory = new ServiceInterfaceFactory(serviceLocator.Object, messengerFactory.Object);
        }
 private static void SendUpdateLicenseMessageToService()
 {
     try
     {
         Log.Information("VpnGui: sending update license to service.");
         PipeChannelFactory pipeChannelFactory = new PipeChannelFactory();
         IService           arg_49_0           = new ServiceInterfaceFactory(new ServiceLocator(), pipeChannelFactory).CreateServiceInterface("VPN");
         bool responceReceived = false;
         arg_49_0.Request(Message.CreateRequest("license/update"), delegate(Message m)
         {
             responceReceived = true;
         }, null);
         Program.WaitUntil(() => responceReceived, 4000);
         pipeChannelFactory.Dispose();
     }
     catch (Exception arg)
     {
         Log.Warning(string.Format("Error on creating communication chanel with service:{0}", arg));
     }
 }