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); }
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"); }