示例#1
0
        void BeginTestMessage2(MessagesTest test, DrpTesterPeerApp peer1, DrpTesterPeerApp peer2)
        {
            var text = $"test{_insecureRandom.Next()}-{_insecureRandom.Next()}_from_{peer1}_to_{peer2}";
            var sw   = Stopwatch.StartNew();

            BeginTestMessage3(test, peer1, peer2, sw, text);
        }
示例#2
0
        void BeginTestMessage(MessagesTest test)
        {
            int c            = test.OnSent();
            var userAppIndex = c % _userApps.Count;
            var peer1        = _userApps[userAppIndex];

_retry:
            var peer2 = _userApps[_insecureRandom.Next(_userApps.Count)];

            if (peer1 == peer2)
            {
                goto _retry;
            }

            _visionChannel.EmitListOfPeers(peer1.DrpPeerEngine.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName, AttentionLevel.guiActivity,
                                           $"testing message #{c} from {peer1} to {peer2}");
            if (userAppIndex == 0)
            {
                peer1.DrpPeerEngine.EngineThreadQueue.EnqueueDelayed(TimeSpan.FromSeconds(1), () => // pause of 1 sec to avoid non-unique INVITE packet fields
                {
                    BeginTestMessage2(test, peer1, peer2);
                }, "testmessage4946");
            }
            else
            {
                BeginTestMessage2(test, peer1, peer2);
            }
        }
示例#3
0
        void BeginTestMessage3(MessagesTest test, DrpTesterPeerApp peer1, DrpTesterPeerApp peer2, Stopwatch sw, string text)
        {
            var userCertificate1 = UserCertificate.GenerateKeyPairsAndSignAtSingleDevice(peer1.DrpPeerEngine.CryptoLibrary, peer1.UserId, peer1.UserRootPrivateKeys, DateTime.UtcNow.AddHours(-1), DateTime.UtcNow.AddHours(1));

            peer1.LocalDrpPeer.BeginSendShortSingleMessage(userCertificate1, peer2.LocalDrpPeer.Configuration.LocalPeerRegistrationId, peer2.UserId, text, TimeSpan.FromSeconds(60), (exc) =>
            {
                BeginVerifyReceivedMessage(test, peer1, peer2, text, sw, Stopwatch.StartNew());
            });
        }
示例#4
0
        void BeginVerifyReceivedMessage(MessagesTest test, DrpTesterPeerApp peer1, DrpTesterPeerApp peer2, string sentText, Stopwatch sw, Stopwatch afterCompletionSw)
        {
            if (peer2.LatestReceivedTextMessage == sentText)
            {
                sw.Stop();
                test.OnSuccessfullyDelivered(sw.Elapsed.TotalMilliseconds, _visionChannel.TimeNow, peer2.LatestReceivedTextMessage_req);
                _visionChannel.EmitListOfPeers(peer1.DrpPeerEngine.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName,
                                               AttentionLevel.guiActivity, $"successfully tested message from {peer1} to {peer2} in {sw.Elapsed.TotalMilliseconds}ms. {test.Report}");
            }
            else
            { // try to wait for 1 sec   in case when sender-side callback is invoked BEFORE receiver-side callback
                if (afterCompletionSw.Elapsed.TotalMilliseconds < 1000)
                {
                    peer2.DrpPeerEngine.EngineThreadQueue.EnqueueDelayed(TimeSpan.FromMilliseconds(10), () =>
                    {
                        BeginVerifyReceivedMessage(test, peer1, peer2, sentText, sw, afterCompletionSw);
                    }, "verifyMsg 247");
                    return;
                }

                _visionChannel.EmitListOfPeers(peer1.DrpPeerEngine.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName,
                                               AttentionLevel.mediumPain,
                                               $"test message failed from {peer1} to {peer2}: received '{peer2.LatestReceivedTextMessage}', expected '{sentText}. {test.Report}");

                var failedCount = test.OnFailed(_visionChannel.TimeNow);
                if (failedCount >= 100)
                {
                    _visionChannel.EmitListOfPeers(peer1.DrpPeerEngine.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName,
                                                   AttentionLevel.strongPain,
                                                   $"disposing the test: {failedCount} messages failed");

                    BeginDisposeOnFailure();
                    return;
                }
            }

            BeginTestMessage(test); // continue with next test message, =between another pair of users
        }