Beispiel #1
0
        public void Setup()
        {
            //EneterTrace.DetailLevel = EneterTrace.EDetailLevel.Debug;
            //EneterTrace.TraceLog = new StreamWriter("d:/trace.txt");

            MessagingSystemFactory = new HttpMessagingSystemFactory();
            ChannelId = "http://127.0.0.1:8091/";
        }
Beispiel #2
0
        public void Setup()
        {
            ChannelId = "http://127.0.0.1:8056/bbb/";
            IMessagingSystemFactory anUnderlyingMessaging = new HttpMessagingSystemFactory(200, 600000);
            TimeSpan aMaxOfflineTime = TimeSpan.FromMilliseconds(1000);

            MessagingSystem = new BufferedMessagingFactory(anUnderlyingMessaging, aMaxOfflineTime);
            ConnectionInterruptionFrequency = 500;
        }
Beispiel #3
0
        public void B01_InactivityTimeout()
        {
            // Set the polling frequency slower
            // than inactivity timeout in the duplex input channel.
            // Therefore the timeout should occur before the polling - this is how the
            // inactivity is simulated in this test.
            IMessagingSystemFactory aMessagingSystem = new HttpMessagingSystemFactory(3000, 2000);

            IDuplexOutputChannel anOutputChannel1 = aMessagingSystem.CreateDuplexOutputChannel(ChannelId);
            IDuplexOutputChannel anOutputChannel2 = aMessagingSystem.CreateDuplexOutputChannel(ChannelId);

            IDuplexInputChannel anInputChannel = aMessagingSystem.CreateDuplexInputChannel(ChannelId);

            AutoResetEvent aConncetionEvent    = new AutoResetEvent(false);
            AutoResetEvent aDisconncetionEvent = new AutoResetEvent(false);

            List <TConnectionEvent> aConnections = new List <TConnectionEvent>();

            anInputChannel.ResponseReceiverConnected += (x, y) =>
            {
                aConnections.Add(new TConnectionEvent(DateTime.Now, y.ResponseReceiverId));
                aConncetionEvent.Set();
            };

            List <TConnectionEvent> aDisconnections = new List <TConnectionEvent>();

            anInputChannel.ResponseReceiverDisconnected += (x, y) =>
            {
                aDisconnections.Add(new TConnectionEvent(DateTime.Now, y.ResponseReceiverId));
                aDisconncetionEvent.Set();
            };

            try
            {
                anInputChannel.StartListening();
                Assert.IsTrue(anInputChannel.IsListening);

                // Create the 1st connection.
                anOutputChannel1.OpenConnection();
                Assert.IsTrue(anOutputChannel1.IsConnected);
                aConncetionEvent.WaitOne();
                Assert.AreEqual(1, aConnections.Count);
                Assert.IsFalse(string.IsNullOrEmpty(aConnections[0].ReceiverId));

                Thread.Sleep(1000);

                // Create the 2nd connection.
                anOutputChannel2.OpenConnection();
                Assert.IsTrue(anOutputChannel2.IsConnected);
                aConncetionEvent.WaitOne();
                Assert.AreEqual(2, aConnections.Count);
                Assert.IsFalse(string.IsNullOrEmpty(aConnections[1].ReceiverId));

                // Wait for the 1st disconnection
                aDisconncetionEvent.WaitOne();

                Assert.AreEqual(1, aDisconnections.Count);
                Assert.AreEqual(aConnections[0].ReceiverId, aDisconnections[0].ReceiverId);
                Assert.IsTrue(aDisconnections[0].Time - aConnections[0].Time > TimeSpan.FromMilliseconds(1900));

                // Wait for the 2nd disconnection
                aDisconncetionEvent.WaitOne();

                Assert.AreEqual(2, aDisconnections.Count);
                Assert.AreEqual(aConnections[1].ReceiverId, aDisconnections[1].ReceiverId);
                Assert.IsTrue(aDisconnections[1].Time - aConnections[1].Time > TimeSpan.FromMilliseconds(1900));
            }
            finally
            {
                anOutputChannel1.CloseConnection();
                anOutputChannel2.CloseConnection();
                anInputChannel.StopListening();
            }
        }