/**********************************************************************************/

        private OadrPoll doPoll()
        {
            OadrPoll oadrPoll = null;

            lock (m_ven) { oadrPoll = m_ven.poll(); }

            m_callbacks.processPoll(oadrPoll);

            if (oadrPoll == null)
            {
                return(null);
            }

            m_serverOffsetSeconds = oadrPoll.serverOffset;

            if (oadrPoll.responseTypeIs(typeof(oadrDistributeEventType)))
            {
                processDistributeEvent(oadrPoll.getDistributeEventResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrRegisterReportType)))
            {
                processRegisterReport(oadrPoll.getRegisterReportResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrCreateReportType)))
            {
                processCreateReport(oadrPoll.getCreateReportResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrCancelReportType)))
            {
                processCancelReport(oadrPoll.getCancelReportResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrCancelPartyRegistrationType)))
            {
                processCancelRegistration(oadrPoll.getCancelPartyRegistrationResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrRequestReregistrationType)))
            {
                handleRegistration(true);
            }

            return(oadrPoll);
        }
        public void N1_0020_TH_VTN_1()
        {
            VEN2b ven = new VEN2b(new HttpWebRequestWrapper(false, System.Net.SecurityProtocolType.Tls12), TestProperties.vtnURL, TestProperties.venName, TestProperties.venID, TestProperties.venPassword);

            // register
            CreatePartyRegistration createPartyRegistration = ven.createPartyRegistration(RandomHex.instance().generateRandomHex(10), oadrProfileType.Item20b, oadrTransportType.simpleHttp, "", false, false, true);

            Assert.IsTrue(createPartyRegistration.response != null);

            Console.Out.WriteLine(createPartyRegistration.responseBody);

            // POLL
            OadrPoll oadrPoll = ven.poll();

            Assert.IsNotNull(oadrPoll.response);

            Console.Out.WriteLine(oadrPoll.responseBody);

            // First request is registerReport
            Assert.IsTrue(oadrPoll.responseTypeIs(typeof(oadrRegisterReportType)));

            oadrRegisterReportType registerReportType = oadrPoll.getRegisterReportResponse();

            RegisteredReport registeredReport = ven.registeredReport(registerReportType.requestID, "200", "OK");

            Assert.IsNotNull(registeredReport.response);
            Assert.AreEqual(registeredReport.response.eiResponse.responseCode, "200");

            // register our own report
            ReportDescription reportDescription = ReportHelper.generateReportDescription();

            RegisterReport registerReport = ven.registerReport(RandomHex.instance().generateRandomHex(10), reportDescription);

            Assert.IsNotNull(registerReport.response);

            Assert.AreEqual("200", registerReport.response.eiResponse.responseCode);

            Assert.AreEqual(registerReport.request.requestID, registerReport.response.eiResponse.requestID);
        }