void DataCache::onObserve(const HeaderOptions & /*_hos*/, const ResponseStatement &_rep, int _result, int _seq) { if (_result != OC_STACK_OK || _rep.getAttributes().empty() || lastSequenceNum > _seq) { return; } else { lastSequenceNum = _seq; } if (state != CACHE_STATE::READY) { state = CACHE_STATE::READY; isReady = true; } if (mode != CACHE_MODE::OBSERVE) { mode = CACHE_MODE::OBSERVE; } networkTimer.cancel(networkTimeOutHandle); networkTimeOutHandle = networkTimer.post(CACHE_DEFAULT_EXPIRED_MILLITIME, pTimerCB); notifyObservers(_rep.getAttributes()); }
void DataCache::onGet(const HeaderOptions & /*_hos*/, const ResponseStatement &_rep, int _result) { if (_result != OC_STACK_OK || _rep.getAttributes().empty()) { return; } if (state != CACHE_STATE::READY) { state = CACHE_STATE::READY; isReady = true; } if (mode != CACHE_MODE::OBSERVE) { networkTimer.cancel(networkTimeOutHandle); networkTimeOutHandle = networkTimer.post( CACHE_DEFAULT_EXPIRED_MILLITIME, pTimerCB); pollingHandle = pollingTimer.post(CACHE_DEFAULT_REPORT_MILLITIME, pPollingCB); } notifyObservers(_rep.getAttributes()); }
void ObserveCache::onObserve(const HeaderOptions &, const ResponseStatement & rep, int _result, unsigned int) { if (!convertOCResultToSuccess((OCStackResult)_result)) { return; } m_state = CACHE_STATE::READY; if (m_attributes == rep.getAttributes()) { return ; } m_attributes = rep.getAttributes(); if (m_reportCB) { m_reportCB(m_wpResource.lock(), m_attributes); } }