示例#1
0
        public void TransmitterConnectivity()
        {
            Transmitter server = new Transmitter(MxpConstants.DefaultHubPort);

            Transmitter client = new Transmitter();

            JoinRequestMessage originalMessage = new JoinRequestMessage();

            originalMessage.BubbleId              = Guid.NewGuid();
            originalMessage.LocationName          = "TestLocation";
            originalMessage.IdentityProviderUrl   = "IdentityProviderUrl";
            originalMessage.ParticipantIdentifier = "TestParticipantName";
            originalMessage.ParticipantSecret     = "TestParticipantPassphrase";
            originalMessage.ParticipantRealTime   = 10;

            originalMessage.ProgramName          = "TestProgramName";
            originalMessage.ProgramMajorVersion  = 1;
            originalMessage.ProgramMinorVersion  = 2;
            originalMessage.ProtocolMajorVersion = 3;
            originalMessage.ProtocolMinorVersion = 4;

            Session clientSession = client.OpenSession("127.0.0.1", MxpConstants.DefaultHubPort, originalMessage);

            clientSession.Send(originalMessage);
            client.Send();

            Assert.AreEqual(1, clientSession.GetPacketWaitingAcknowledgeCount());

            Thread.Sleep(100);

            server.Receive();

            server.Send();

            Thread.Sleep(100);

            client.Receive();

            client.HandleControlMessages();

            Assert.AreEqual(0, clientSession.GetPacketWaitingAcknowledgeCount());

            Session serverSession = server.AcceptPendingSession();

            Message decodedMessage = serverSession.Receive();

            decodedMessage.IsAutoRelease = false;

            String originalMessageString = originalMessage.ToString();
            String decodedMessageString  = decodedMessage.ToString();

            Assert.AreEqual(originalMessageString, decodedMessageString);

            server.Shutdown();

            Thread.Sleep(100);
        }