StartListening() публичный Метод

Start listening.
public StartListening ( ) : void
Результат void
        public void HostedCacheServer_PchcServer_SegmentInfo_HashAlgoInvalid()
        {
            CheckApplicability();

            var contentInformation = contentInformationUtility.CreateContentInformationV1();

            using (var pccrrServer = new PccrrServer(testConfig.ClientContentRetrievalListenPort))
            {
                pccrrServer.StartListening();

                pccrrServer.MessageArrived += new MessageArrivedEventArgs(delegate(IPEndPoint sender, PccrrPacket pccrrPacket)
                {
                    BaseTestSite.Assert.Fail("Hosted cache server should not retrieve content information with invalid hash algorithm");
                });

                PCHCClient pchcClient = new PCHCClient(
                    TransferProtocol.HTTPS,
                    testConfig.HostedCacheServerComputerName,
                    testConfig.HostedCacheServerHTTPSListenPort,
                    PchcConsts.HttpsUrl,
                    testConfig.DomainName,
                    testConfig.UserName,
                    testConfig.UserPassword);

                var segmentInfo = pchcClient.CreateSegmentInfoMessage(
                    testConfig.ClientContentRetrievalListenPort,
                    contentInformation,
                    0);

                segmentInfo.SegmentInfo.dwHashAlgo = (dwHashAlgo_Values)0xFEFE;

                var segmentInfoResponse = pchcClient.SendSegmentInfoMessage(segmentInfo);

                BaseTestSite.Assert.AreEqual(
                    RESPONSE_CODE.OK,
                    segmentInfoResponse.ResponseCode,
                    "Hosted cache server should return OK to segment info message");

                Thread.Sleep(testConfig.NegativeTestTimeout);
            }
        }
        public void HostedCacheServer_PchcServer_BatchedOffer_SegmentDescriptorTooMany()
        {
            CheckApplicability();

            var contentInformation = contentInformationUtility.CreateContentInformationV2();

            using (var pccrrServer = new PccrrServer(testConfig.ClientContentRetrievalListenPort))
            {
                pccrrServer.StartListening();

                pccrrServer.MessageArrived += new MessageArrivedEventArgs(delegate(IPEndPoint sender, PccrrPacket pccrrPacket)
                {
                    BaseTestSite.Assert.Fail("Hosted cache server should not retrieve content information with more than 128 segment descriptions");
                });

                PCHCClient pchcClient = new PCHCClient(
                    TransferProtocol.HTTP,
                    testConfig.HostedCacheServerComputerName,
                    testConfig.HostedCacheServerHTTPListenPort,
                    PchcConsts.HttpUrl,
                    testConfig.DomainName,
                    testConfig.UserName,
                    testConfig.UserPassword);

                var batchedOffer = pchcClient.CreateBatchedOfferMessage(
                    testConfig.ClientContentRetrievalListenPort,
                    contentInformation);

                List<SegmentDescriptor> segmentDescriptors = new List<SegmentDescriptor>();
                for (int i = 0; i < 129; i++)
                {
                    segmentDescriptors.Add(batchedOffer.SegmentDescriptors[0]);
                }
                batchedOffer.SegmentDescriptors = segmentDescriptors.ToArray();

                bool passed = false;
                try
                {
                    pchcClient.SendBatchedOfferMessage(batchedOffer);
                }
                catch
                {
                    passed = true;
                }

                BaseTestSite.Assert.IsTrue(passed, "Hosted cache server should drop invalid batched offer request");
            }
        }
        public void HostedCacheServer_PchcServer_BatchedOffer_HashAlgoInvalid()
        {
            CheckApplicability();

            var contentInformation = contentInformationUtility.CreateContentInformationV2();

            using (var pccrrServer = new PccrrServer(testConfig.ClientContentRetrievalListenPort))
            {
                pccrrServer.StartListening();

                pccrrServer.MessageArrived += new MessageArrivedEventArgs(delegate(IPEndPoint sender, PccrrPacket pccrrPacket)
                {
                    BaseTestSite.Assert.Fail("Hosted cache server should not retrieve content information with more than 128 segment descriptions");
                });

                PCHCClient pchcClient = new PCHCClient(
                    TransferProtocol.HTTP,
                    testConfig.HostedCacheServerComputerName,
                    testConfig.HostedCacheServerHTTPListenPort,
                    PchcConsts.HttpUrl,
                    testConfig.DomainName,
                    testConfig.UserName,
                    testConfig.UserPassword);

                var batchedOffer = pchcClient.CreateBatchedOfferMessage(
                    testConfig.ClientContentRetrievalListenPort,
                    contentInformation);

                batchedOffer.SegmentDescriptors[0].HashAlgorithm = 0xFE;

                var batchedOfferResponse = pchcClient.SendBatchedOfferMessage(batchedOffer);

                BaseTestSite.Assert.AreEqual(
                    RESPONSE_CODE.OK,
                    batchedOfferResponse.ResponseCode,
                    "Hosted cache server should return OK to batched offer message");

                Thread.Sleep(testConfig.NegativeTestTimeout);
            }
        }
        public void HostedCacheServer_PchcServer_GetBlocks_SizeOfBlockNotMatch()
        {
            CheckApplicability();

            var contentInformation = contentInformationUtility.CreateContentInformationV1();

            using (var pccrrServer = new PccrrServer(testConfig.ClientContentRetrievalListenPort))
            {
                bool blockRetrieved = false;
                pccrrServer.MessageArrived += new MessageArrivedEventArgs(delegate(IPEndPoint sender, PccrrPacket pccrrPacket)
                    {
                        var pccrrGetBlkRequest = (PccrrGETBLKSRequestPacket)pccrrPacket;

                        if (pccrrGetBlkRequest != null)
                        {
                            BaseTestSite.Log.Add(
                                LogEntryKind.Debug,
                                "PCCRR GetBlks request received from hosted cache server. Send malformed Blks response");

                            var pccrrBlocksResponse = pccrrServer.CreateMsgBlkResponse(
                                pccrrGetBlkRequest.MsgGetBLKS.SegmentID,
                                TestUtility.GenerateRandomArray(ContentInformationUtility.DefaultBlockSize),
                                CryptoAlgoId_Values.AES_128,
                                MsgType_Values.MSG_BLK,
                                TestUtility.GenerateRandomArray(16),
                                0,
                                0);
                            var blk = pccrrBlocksResponse.MsgBLK;
                            blk.SizeOfBlock = 0;
                            pccrrBlocksResponse.MsgBLK = blk;
                            pccrrServer.SendPacket(pccrrBlocksResponse);

                            blockRetrieved = true;
                        }
                    });
                pccrrServer.StartListening();

                PCHCClient pchcClient = new PCHCClient(
                    TransferProtocol.HTTPS,
                    testConfig.HostedCacheServerComputerName,
                    testConfig.HostedCacheServerHTTPSListenPort,
                    PchcConsts.HttpsUrl,
                    testConfig.DomainName,
                    testConfig.UserName,
                    testConfig.UserPassword);

                BaseTestSite.Log.Add(
                    LogEntryKind.Debug,
                    "Offer block to hosted cache server");

                SEGMENT_INFO_MESSAGE segmentInfoMessage = pchcClient.CreateSegmentInfoMessage(
                    testConfig.ClientContentRetrievalListenPort,
                    contentInformation,
                    0);
                pchcClient.SendSegmentInfoMessage(segmentInfoMessage);

                TestUtility.DoUntilSucceed(() =>
                {
                    return blockRetrieved;
                }, testConfig.Timeout, testConfig.RetryInterval);
            }

            BaseTestSite.Log.Add(
                LogEntryKind.Debug,
                "Try to retrieve the block from hosted cache server");

            PccrrClient pccrrClient = new PccrrClient(
                testConfig.HostedCacheServerComputerName,
                testConfig.HostedCacheServerHTTPListenPort);

            PccrrGETBLKSRequestPacket pccrrBlkRequest = pccrrClient.CreateMsgGetBlksRequest(
                contentInformation.GetSegmentId(0),
                CryptoAlgoId_Values.AES_128,
                MsgType_Values.MSG_GETBLKS,
                0,
                1);
            pccrrClient.SendPacket(
                pccrrBlkRequest,
                testConfig.Timeout);
            PccrrBLKResponsePacket pccrrBlkResponse
                = (PccrrBLKResponsePacket)pccrrClient.ExpectPacket();

            BaseTestSite.Assert.AreEqual<uint>(
                0,
                pccrrBlkResponse.MsgBLK.SizeOfBlock,
                "The server MUST set the SizeOfBlock field to zero if blocks data is not available.");
        }
        public void Start(int port, CryptoAlgoId_Values cryptoAlgoId, ProtoVersion protoVersion, byte[] content, EventQueue eventQueue)
        {
            this.cryptoAlgoId = cryptoAlgoId;
            this.protoVersion = protoVersion;
            this.content = content;
            this.eventQueue = eventQueue;
            this.aes = PccrrUtitlity.CreateAes(cryptoAlgoId);
            this.iv = new byte[16];
            for (int i = 0; i < iv.Length; i++)
            {
                this.iv[i] = (byte)i;
            }

            pccrrServer = new PccrrServer(port);

            pccrrServer.MessageArrived += new MessageArrivedEventArgs(pccrrServer_MessageArrived);

            pccrrServer.StartListening();
        }