Observation without caching.
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / resourceCache / src / ObserveCache.cpp
index 608aa75..cf0e128 100644 (file)
@@ -31,7 +31,7 @@ namespace OIC
         {
         }
 
-        void ObserveCache::startCache(DataCacheCB func)
+        void ObserveCache::startCache(DataCacheCB func, bool reportAll)
         {
             if (m_isStart)
             {
@@ -53,7 +53,7 @@ namespace OIC
                         std::bind(&ObserveCache::verifyObserveCB,
                                   std::placeholders::_1, std::placeholders::_2,
                                   std::placeholders::_3, std::placeholders::_4,
-                                  shared_from_this()));
+                                  shared_from_this(), reportAll));
             }
             else
             {
@@ -100,14 +100,18 @@ namespace OIC
         }
 
         void ObserveCache::onObserve(const HeaderOptions &,
-                       const ResponseStatement & rep, int _result, unsigned int)
+                       const ResponseStatement & rep, int _result, unsigned int, bool reportAll)
         {
+
+            std::cout << "onObserve (observecache.cpp) reportAll: " << reportAll << std::endl;
+
+            std::lock_guard<std::mutex> lock(m_cbMutex);
             m_state = CACHE_STATE::READY;
 
-            if (m_attributes == rep.getAttributes() &&
+            if (!reportAll && m_attributes == rep.getAttributes() &&
                     convertOCResultToSuccess((OCStackResult)_result))
             {
-                return ;
+                return;
             }
 
             if (m_reportCB)
@@ -119,12 +123,12 @@ namespace OIC
 
         void ObserveCache::verifyObserveCB(const HeaderOptions &_hos,
                                     const ResponseStatement &_rep, int _result,
-                                    unsigned int _seq, weakDataCache wPtr)
+                                    unsigned int _seq, weakDataCache wPtr, bool reportAll)
         {
             auto ptr = wPtr.lock();
             if (ptr)
             {
-                ptr->onObserve(_hos, _rep, _result, _seq);
+                ptr->onObserve(_hos, _rep, _result, _seq, reportAll);
             }
         }
 
@@ -135,7 +139,9 @@ namespace OIC
                 case OC_STACK_OK:
                 case OC_STACK_RESOURCE_CREATED:
                 case OC_STACK_RESOURCE_DELETED:
+#ifdef WITH_PRESENCE
                 case OC_STACK_PRESENCE_STOPPED:
+#endif
                 case OC_STACK_CONTINUE:
                 case OC_STACK_RESOURCE_CHANGED:
                     return true;