+void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int nonce,
+ const std::string &hostAddress)
+{
+ SSMRESULT res = SSM_E_FAIL;
+ OCStackResult ret = OC_STACK_ERROR;
+ intptr_t *pMessage = NULL;
+ std::ostringstream requestURI;
+
+ switch (result)
+ {
+ case OC_STACK_OK:
+ requestURI << "coap://" << hostAddress << ":" << OC_MULTICAST_PORT <<
+ "/oc/core?rt=SoftSensorManager.Sensor";
+
+ ret = OC::OCPlatform::findResource("", requestURI.str(), OC_WIFI,
+ std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+
+ if (ret != OC_STACK_OK)
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+
+ break;
+
+ case OC_STACK_PRESENCE_STOPPED:
+ case OC_STACK_PRESENCE_TIMEOUT:
+ if (m_mapResources.find(hostAddress) != m_mapResources.end())
+ {
+ while (!m_mapResources[hostAddress].empty())
+ {
+ pMessage = new intptr_t[2];
+ pMessage[0] = RESOURCE_DISCOVER_UNINSTALL_RESOURCE;
+ pMessage[1] = reinterpret_cast<intptr_t> (m_mapResourceHandler[m_mapResources[hostAddress].back()]);
+ m_mapResources[hostAddress].pop_back();
+ m_pTasker->addTask(this, pMessage);
+ }
+
+ m_mapResources.erase(hostAddress);
+ }
+ break;
+
+ case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
+ break;
+
+ default:
+ break;
+ }
+
+CLEANUP:
+ ;
+}
+