public void AttachInputChannel() { anInputChannel = UnderlyingMessaging.CreateDuplexInputChannel(Self); switch (MessagesFactoryType) { case YZXMessagesFactoryType.Duplex: DReceiver.AttachDuplexInputChannel(anInputChannel); break; } }
public void B03_Pinging_NoResponseForPing() { // Create duplex input channel which will not send ping messages. IDuplexInputChannel aDuplexInputChannel = UnderlyingMessaging.CreateDuplexInputChannel(ChannelId); IDuplexOutputChannel aDuplexOutputChannel = MessagingSystemFactory.CreateDuplexOutputChannel(ChannelId); AutoResetEvent aDisconnectedEvent = new AutoResetEvent(false); bool aDisconnectedFlag = false; aDuplexOutputChannel.ConnectionClosed += (x, y) => { aDisconnectedFlag = true; aDisconnectedEvent.Set(); }; try { // Start listening. aDuplexInputChannel.StartListening(); // Allow some time for pinging. aDuplexOutputChannel.OpenConnection(); Assert.IsTrue(aDuplexOutputChannel.IsConnected); Thread.Sleep(2000); aDisconnectedEvent.WaitOne(); Assert.IsTrue(aDisconnectedFlag); Assert.IsFalse(aDuplexOutputChannel.IsConnected); } finally { aDuplexOutputChannel.CloseConnection(); aDuplexInputChannel.StopListening(); } }