When using the C++ SDK, how does a callback associated with 
OC::OCPlatform::findResource get unregistered and the associated memory freed?  
The client examples, call findResource and show the results that are found then 
wait forever, which is fine if the application only calls findResource once or 
twice.  An application, might want to call findResource multiple times to 
determine if new devices are present, for example to determine which mobile 
devices are in the room.  If the resourceHandler depends on objects that are 
taking up memory, I would like to free them, but I would also like to be 
certain that the resource handler will not be called after memory is freed.

I did not see any discussion about it in the Doxygen docs, so I looked in the 
code.  It looks like InProcClientWrapper::ListenForResource() is registering a 
callback, called listenCallback() to call the application callback in 
InProcClientWrapper.cpp.  InProcClientWrapper::ListenForResource() passes 
nullptr as the handle parameter to OCDoResource(), so it cannot be calling 
OCCancel() on it later, because it does not have the handle.  All of the return 
paths from listenCallback() return OC_STACK_KEEP_TRANSACTION, which tells the 
stack to keep the callback active.

Is there some other means by which the callback is getting unregistered?

Thanks,
Bill.

Reply via email to