summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSourav Bhuwalka <s.bhuwalka@samsung.com>2020-01-24 18:30:49 +0530
committerDoHyun Pyun <dh79.pyun@samsung.com>2020-02-19 09:10:23 +0900
commit17f06068e66a222013ed6280497a43c9abdfde5e (patch)
tree4030e52e3aa913d9bd66ca9f8a4f93c1f6009e98
parentdaef13e9901a25656dbea914d2a5bf92a755fc1d (diff)
downloadiotivity-17f06068e66a222013ed6280497a43c9abdfde5e.tar.gz
iotivity-17f06068e66a222013ed6280497a43c9abdfde5e.tar.bz2
iotivity-17f06068e66a222013ed6280497a43c9abdfde5e.zip
[CONPRO-1549] Create new method in RDClient
Added new (publishAllResourceToRD) to publish resources to resource- directory.Dont include virtual resources /oic/p and /oic/d to resourceHandles argument of this API.This API internally appends the two virtual resources. https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/655 (cherry-picked from 3f75969eec27bc8b6264de42faf01cf811de5037) Change-Id: I3a6877d885d8c1537b2d767d06f8e1e1e9acd8cd Signed-off-by: Sourav Bhuwalka <s.bhuwalka@samsung.com> Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
-rw-r--r--resource/csdk/resource-directory/include/RDClient.h24
-rw-r--r--resource/csdk/resource-directory/src/RDClient.cpp41
2 files changed, 65 insertions, 0 deletions
diff --git a/resource/csdk/resource-directory/include/RDClient.h b/resource/csdk/resource-directory/include/RDClient.h
index 39e9edcbd..f34465206 100644
--- a/resource/csdk/resource-directory/include/RDClient.h
+++ b/resource/csdk/resource-directory/include/RDClient.h
@@ -93,6 +93,30 @@ public:
QualityOfService qos);
/**
+ * API for All Resources Publish to Resource Directory.
+ * @note This API internally includes Virtual Resource("/oic/d" and "/oic/p") apart
+ * from resource Handles passed.Do not add virtual resource handles in the
+ * resourceHandles argument of this API.
+ *
+ * @param host Host IP Address of a service to direct resource publish query.
+ * @param connectivityType ::OCConnectivityType type of connectivity.
+ * @param callback Handles callbacks, success states and failure states.
+ *
+ * @return Returns ::OC_STACK_OK if success.
+ */
+
+ OCStackResult publishAllResourceToRD(const std::string& host,
+ OCConnectivityType connectivityType,
+ OC::ResourceHandles& resourceHandles,
+ PublishResourceCallback callback);
+
+ OCStackResult publishAllResourceToRD(const std::string& host,
+ OCConnectivityType connectivityType,
+ OC::ResourceHandles& resourceHandles,
+ PublishResourceCallback callback,
+ QualityOfService qos);
+
+ /**
* API for published resource delete from Resource Directory.
* @note This API applies to resource server side only.
*
diff --git a/resource/csdk/resource-directory/src/RDClient.cpp b/resource/csdk/resource-directory/src/RDClient.cpp
index c4ac211ae..6cd035598 100644
--- a/resource/csdk/resource-directory/src/RDClient.cpp
+++ b/resource/csdk/resource-directory/src/RDClient.cpp
@@ -127,6 +127,14 @@ OCStackResult RDClient::publishResourceToRD(const std::string& host,
return publishResourceToRD(host, connectivityType, resourceHandles, callback, static_cast<QualityOfService>(m_qos));
}
+OCStackResult RDClient::publishAllResourceToRD(const std::string& host,
+ OCConnectivityType connectivityType,
+ ResourceHandles& resourceHandles,
+ PublishResourceCallback callback)
+{
+ return publishAllResourceToRD(host, connectivityType, resourceHandles, callback, static_cast<QualityOfService>(m_qos));
+}
+
OCStackResult RDClient::publishResourceToRD(const std::string& host,
OCConnectivityType connectivityType,
PublishResourceCallback callback,
@@ -167,6 +175,39 @@ OCStackResult RDClient::publishResourceToRD(const std::string& host,
return result;
}
+OCStackResult RDClient::publishAllResourceToRD(const std::string& host,
+ OCConnectivityType connectivityType,
+ ResourceHandles& resourceHandles,
+ PublishResourceCallback callback,
+ QualityOfService qos)
+{
+ ServerCallbackContext::PublishContext* ctx =
+ new ServerCallbackContext::PublishContext(callback);
+ OCCallbackData cbdata(
+ static_cast<void*>(ctx),
+ publishResourceToRDCallback,
+ [](void* c)
+ {delete static_cast<ServerCallbackContext::PublishContext*>(c);}
+ );
+
+ auto cLock = m_csdkLock.lock();
+ OCStackResult result = OC_STACK_ERROR;
+ if (cLock)
+ {
+ std::lock_guard<std::recursive_mutex> lock(*cLock);
+ resourceHandles.push_back( OCGetResourceHandleAtUri(OC_RSRVD_DEVICE_URI) );
+ resourceHandles.push_back( OCGetResourceHandleAtUri(OC_RSRVD_PLATFORM_URI) );
+ result = OCRDPublish(nullptr, host.c_str(), connectivityType, &resourceHandles[0],
+ resourceHandles.size(), &cbdata, static_cast<OCQualityOfService>(qos));
+ }
+
+ if (OC_STACK_OK != result)
+ {
+ throw OCException(OC::Exception::PUBLISH_RESOURCE_FAILED, result);
+ }
+ return result;
+}
+
OCStackApplicationResult deleteResourceFromRDCallback(void* ctx, OCDoHandle /*handle*/,
OCClientResponse* clientResponse)
{