Fixing OCCancel with High_QOS in observe isn't deleting CB.
authorYamin Al-Mousa <yamin.s.al-mousa@intel.com>
Wed, 7 Jan 2015 18:14:10 +0000 (10:14 -0800)
committerYamin Al-Mousa <yamin.s.al-mousa@intel.com>
Wed, 7 Jan 2015 18:14:10 +0000 (10:14 -0800)
(Bug IOT-126) Calling OCCancel should result in deleting all
associated structures including callbacks. This also should
happen when we deregister observation.

Change-Id: I34dd67288873ce27919a12a1d5fe244ef80751b7
Signed-off-by: Yamin Al-Mousa <yamin.s.al-mousa@intel.com>
resource/examples/simpleclientHQ.cpp
resource/src/InProcClientWrapper.cpp

index e3a6f2c..bc29da0 100644 (file)
@@ -62,11 +62,11 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
     if(eCode == SUCCESS_RESPONSE)
     {
         std::cout << "OBSERVE RESULT:"<<std::endl;
-        if(sequenceNumber == 0)
+        if(sequenceNumber == (int) ObserveAction::ObserveRegister)
         {
             std::cout << "\tObserve Registration Confirmed: "<< endl;
         }
-        else if (sequenceNumber == 1)
+        else if (sequenceNumber == (int) ObserveAction::ObserveUnregister)
         {
             std::cout << "\tObserve Cancel Confirmed: "<< endl;
             sleep(10);
index 83e4ef8..8f1a455 100644 (file)
@@ -551,7 +551,6 @@ namespace OC
         OCRepresentation attrs;
         HeaderOptions serverHeaderOptions;
         uint32_t sequenceNumber = clientResponse->sequenceNumber;
-
         if(clientResponse->result == OC_STACK_OK)
         {
             parseServerHeaderOptions(clientResponse, serverHeaderOptions);
@@ -560,6 +559,10 @@ namespace OC
         std::thread exec(context->callback, serverHeaderOptions, attrs,
                     clientResponse->result, sequenceNumber);
         exec.detach();
+        if(sequenceNumber == OC_OBSERVE_DEREGISTER)
+        {
+            return OC_STACK_DELETE_TRANSACTION;
+        }
         return OC_STACK_KEEP_TRANSACTION;
     }