Ejemplo n.º 1
0
        public void TestChannelCreation()
        {
            MultichannelConnection mc1 = new MultichannelConnection(serverConnection);
            var s1 = mc1.CreateChannel();
            var s2 = mc1.CreateChannel();

            MultichannelConnection mc2 = new MultichannelConnection(clientConnection);
            var c1 = mc2.CreateChannel();
            var c2 = mc2.CreateChannel();
        }
Ejemplo n.º 2
0
        public void TestDualChannel()
        {
            MultichannelConnection mc1 = new MultichannelConnection(serverConnection);
            var s1 = mc1.CreateChannel();
            var s2 = mc1.CreateChannel();

            MultichannelConnection mc2 = new MultichannelConnection(clientConnection);
            var c1 = mc2.CreateChannel();
            var c2 = mc2.CreateChannel();

            var srecv1 = new List<object>();
            s1.Received += delegate(object sender, ReceivedEventArgs e)
            {
                srecv1.Add(e.Message);
            };

            var srecv2 = new List<object>();
            s2.Received += delegate(object sender, ReceivedEventArgs e)
            {
                srecv2.Add(e.Message);
            };

            var crecv1 = new List<object>();
            c1.Received += delegate(object sender, ReceivedEventArgs e)
            {
                crecv1.Add(e.Message);
            };

            var crecv2 = new List<object>();
            c2.Received += delegate(object sender, ReceivedEventArgs e)
            {
                crecv2.Add(e.Message);
            };

            c1.Send("HI");
            s2.Send("HI YOURSELF");
            c2.Send("HELLO WORLD");
            s1.Send("OH HAI");

            TestUtil.WaitUntil(() => CollectionAssert.AreEqual(new object[]{"HI"}, srecv1), maxWaitTime);
            TestUtil.WaitUntil(() => CollectionAssert.AreEqual(new object[]{"HELLO WORLD"}, srecv2), maxWaitTime);
            TestUtil.WaitUntil(() => CollectionAssert.AreEqual(new object[]{"OH HAI"}, crecv1), maxWaitTime);
            TestUtil.WaitUntil(() => CollectionAssert.AreEqual(new object[]{"HI YOURSELF"}, crecv2), maxWaitTime);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Establishes a shared session using an existing connection.
        /// </summary>
        /// <param name="siteId">The siteId that is used for the current session.</param>
        /// <param name="connection">The connection that we will be synchronizing over.</param>
        public void EstablishSharedSession(int siteId, IConnection connection)
        {
            MultichannelConnection mcc = new MultichannelConnection(connection);
            SynchronizationConnection = mcc.CreateChannel();
            ApplicationConnection = mcc.CreateChannel();

            State = SessionStates.Disconnected;
            SiteId = siteId;
            ActivateState(new BootstrappingState(this));

            // TODO: this has to be altered when support for multiple sites is added
            int otherSiteId = siteId == 0 ? 1 : 0;
            // We store the the connection's site id per connection
            ApplicationConnection.Tag = otherSiteId;
            SynchronizationConnection.Tag = otherSiteId;
        }
Ejemplo n.º 4
0
 public TunneledConnection(MultichannelConnection tunnel)
 {
     this.tunnel = tunnel;
 }
Ejemplo n.º 5
0
        public void TestTooManyChannels()
        {
            MultichannelConnection mc1 = new MultichannelConnection(serverConnection);
            var s1 = mc1.CreateChannel();

            MultichannelConnection mc2 = new MultichannelConnection(clientConnection);
            var c1 = mc2.CreateChannel();
            var c2 = mc2.CreateChannel();

            var srecv1 = new List<object>();
            s1.Received += delegate(object sender, ReceivedEventArgs e)
            {
                srecv1.Add(e.Message);
            };

            c2.Send("THIS SHOULD BE IGNORED");
        }