public IntercomMasterDispatcher(string pipeName, Func <TService> serviceFactory) { _pipeName = pipeName; _serviceFactory = serviceFactory; _dispatchedChannels = new List <IntercomDuplexChannel <TService, TCallback> >(); _serverChannel = new IntercomServerChannel <IDispatcherService>(this, pipeName + Constants.Dispatcher, true); }
public void TestChannelDispose() { string pipeName = "Vkm.TestPipe2"; var service = new Test1(); IntercomServerChannel <Test1> serverChannel = new IntercomServerChannel <Test1>(service, pipeName); IntercomClientChannel <Test1> clientChannel = new IntercomClientChannel <Test1>(pipeName); clientChannel.Connect(); object disposed = null; serverChannel.ConnectionClosed += (sender, args) => disposed = new object(); Assert.AreEqual(null, disposed); clientChannel.Dispose(); Thread.Sleep(500); Assert.AreNotEqual(null, disposed); }
public void TestChannels() { string pipeName = "Vkm.TestPipe1"; var service = new Test1(); IntercomClientChannel <Test1> clientChannel = new IntercomClientChannel <Test1>(pipeName); var task = clientChannel.ConnectAsync(); IntercomServerChannel <Test1> serverChannel = new IntercomServerChannel <Test1>(service, pipeName); task.Wait(); Assert.AreEqual(0, service.MethodCallCount); var r = clientChannel.Execute(nameof(Test1.Do), 5, 7); Assert.AreEqual(1, service.MethodCallCount); Assert.AreEqual(5 * 7, r); r = clientChannel.Execute(nameof(Test1.Do), 11, -11); Assert.AreEqual(2, service.MethodCallCount); Assert.AreEqual(-11 * 11, r); }