示例#1
0
        public void AttachInputChannel()
        {
            anInputChannel = UnderlyingMessaging.CreateDuplexInputChannel(Self);

            switch (MessagesFactoryType)
            {
            case YZXMessagesFactoryType.Duplex:
                DReceiver.AttachDuplexInputChannel(anInputChannel);
                break;
            }
        }
示例#2
0
        public YZXMessagingClient(string partner,
                                  YZXMessagesFactoryType messagetype = YZXMessagesFactoryType.Duplex)
        {
            Partner = partner;

            DSender = DSenderFactory.CreateDuplexTypedMessageSender <ResponseType, RequestType>();

            anOutputChannel = UnderlyingMessaging.CreateDuplexOutputChannel(Partner);



            ConfigSender();

            AttachOutputChannel();
        }
        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();
            }
        }
示例#4
0
 public void AttachOutputChannel()
 {
     try
     {
         switch (MessagesFactoryType)
         {
         case YZXMessagesFactoryType.Duplex:
             if (DSender == null)
             {
                 ConfigSender();
             }
             else
             {
                 if (DSender.IsDuplexOutputChannelAttached)
                 {
                 }
                 else
                 {
                     try
                     {
                         anOutputChannel = UnderlyingMessaging.CreateDuplexOutputChannel(Partner);
                         DSender.AttachDuplexOutputChannel(anOutputChannel);
                     }
                     catch (Exception ex)
                     {
                         Console.WriteLine(ex);
                     }
                 }
             }
             break;
         }
     }
     catch (Exception EX)
     {
         Console.WriteLine(EX);
     }
 }