Apply to Resource Hosting to RE resource server added feature.
[platform/upstream/iotivity.git] / service / resource-hosting / SampleApp / linux / sampleProvider / SampleProvider.cpp
index d44bcb5..bb99443 100644 (file)
@@ -63,7 +63,7 @@ class TempHumidResource
         void createResource()
         {
             std::string resourceURI = "/a/TempHumSensor/hosting";
-            std::string resourceTypeName = "resource.hosting";
+            std::string resourceTypeName = "oic.r.resourcehosting";
             std::string resourceInterface = DEFAULT_INTERFACE;
 
             m_uri = resourceURI;
@@ -83,7 +83,7 @@ class TempHumidResource
         {
             std::string resourceURI = "/a/NM/TempHumSensor1"; // URI of the resource
             std::string resourceTypeName =
-                "notificationmanager.hosting"; // resource type name. In this case, it is light
+                "oic.r.resourcehosting"; // resource type name.
             std::string resourceInterface = DEFAULT_INTERFACE; // resource interface.
 
             // OCResourceProperty is defined ocstack.h
@@ -273,6 +273,22 @@ OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request
             else if (requestType == "POST")
             {
                 cout << "\t\t\trequestType : POST\n";
+                OCRepresentation rep = request->getResourceRepresentation();
+                myResource.put(rep);
+
+                if (pResponse)
+                {
+                    pResponse->setErrorCode(200);
+                    pResponse->setResourceRepresentation(myResource.get());
+                }
+                if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                {
+                    ehResult = OC_EH_OK;
+                }
+                else
+                {
+                    cout << "post request Error\n";
+                }
             }
 
             else if (requestType == "DELETE")