{
SCOPE_LOG_F(DEBUG, TAG);
+ std::shared_ptr<RCSRemoteResourceObject> resource = resourcePtr.lock();
+ if(!resource)
+ {
+ OIC_LOG(ERROR, TAG, "Resource object is null");
+ return OC_STACK_OK;
+ }
+
//If error code is failure then RE Cache module should
//do clean up for caching flags, maps etc.
if(eCode > 4)
{
- OIC_LOG_V(ERROR, TAG, "Error code: %d",eCode);
+ OIC_LOG_V(ERROR, TAG, "Error code: %d", eCode);
try
{
- std::shared_ptr<RCSRemoteResourceObject> resource = resourcePtr.lock();
- if(resource)
- {
- resource->stopCaching();
- }
- else
- {
- OIC_LOG(ERROR, TAG, "Resource object is null");
- }
+ resource->stopCaching();
}
catch(...)
{
//Exception will be thrown: stack will return OC_STACK_ERROR
- // if it already stopped observe. This call is reqired for clearing
+ //if it already stopped observe. This call is reqired for clearing
//Cache manager.
OIC_LOG(DEBUG, TAG, "Cleared Cache");
}
}
}
+ std::weak_ptr< RCSRemoteResourceObject > RCSRemoteResourceObject::weakFromThis()
+ {
+ return shared_from_this();
+ }
+
RCSRemoteResourceObject::Ptr RCSRemoteResourceObject::fromOCResource(
std::shared_ptr< OC::OCResource > ocResource)
{
m_primitiveResource,
std::bind(cachingCallback, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3,
- std::move(cb), shared_from_this()), CACHE_METHOD::OBSERVE_ONLY,
+ std::move(cb), weakFromThis()), CACHE_METHOD::OBSERVE_ONLY,
freq, 0);
}
-
else if (cb)
{
m_cacheId = ResourceCacheManager::getInstance()->requestResourceCache(
m_primitiveResource,
std::bind(cachingCallback, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3,
- std::move(cb), shared_from_this()), CACHE_METHOD::ITERATED_GET,
+ std::move(cb), weakFromThis()), CACHE_METHOD::ITERATED_GET,
freq, 0);
}
else