- auto cLock = m_csdkLock.lock();
-
- if (cLock)
- {
- std::lock_guard < std::recursive_mutex > lock(*cLock);
-
- if (NULL != eHandler)
- {
- result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
- resourceTypeName.c_str(), // const char * resourceTypeName
- resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix
- resourceHOST.c_str(), // const char * host
- (resourceHOST + resourceURI).c_str(), // const char * uri
- EntityHandlerWrapper, // OCEntityHandler entityHandler
- resourceProperties // uint8_t resourceProperties
- );
- }
- else
- {
- result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
- resourceTypeName.c_str(), // const char * resourceTypeName
- resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix
- resourceHOST.c_str(), // const char * host
- (resourceHOST + resourceURI).c_str(), // const char * uri
- nullptr, // OCEntityHandler entityHandler
- resourceProperties // uint8_t resourceProperties
- );
- }
-
- if (result != OC_STACK_OK)
- {
- resourceHandle = nullptr;
- }
- else
- {
- std::lock_guard<std::mutex> lock(OC::details::serverWrapperLock);
- OC::details::entityHandlerMap[resourceHandle] = eHandler;
- OC::details::resourceUriMap[resourceHandle] = resourceURI;
- }
- }
- else
- {
- result = OC_STACK_ERROR;
- }
-
- return result;
- }