replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / resource-container / examples / ContainerSampleClient.cpp
index 0c25b12..60993a8 100644 (file)
@@ -1,6 +1,6 @@
 //******************************************************************
 //
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+// Copyright 2015 Samsung Electronics All Rights Reserved.
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 //
@@ -18,8 +18,7 @@
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
-// OCClient.cpp : Defines the entry point for the console application.
-//
+
 #include <string>
 #include <map>
 #include <cstdlib>
@@ -181,9 +180,13 @@ void onPost2(const HeaderOptions &headerOptions, const OCRepresentation &rep, co
             }
 
             if (OBSERVE_TYPE_TO_USE == ObserveType::Observe)
+            {
                 std::cout << std::endl << "Observe is used." << std::endl << std::endl;
+            }
             else if (OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
+            {
                 std::cout << std::endl << "ObserveAll is used." << std::endl << std::endl;
+            }
 
             curResource->observe(OBSERVE_TYPE_TO_USE, QueryParamsMap(), &onObserve);
 
@@ -255,7 +258,7 @@ void postLightRepresentation(std::shared_ptr<OCResource> resource)
 
         std::cout << "Posting light representation..." << std::endl;
 
-        mylight.m_on_off = "false";
+        mylight.m_on_off = false;
 
         rep.setValue("on-off", mylight.m_on_off);
 
@@ -341,7 +344,7 @@ void putLightRepresentation(std::shared_ptr<OCResource> resource)
 
         // Invoke resource's put API with rep, query map and the callback parameter
 
-        resource->put(rep, QueryParamsMap(), &onPut);
+        resource->post(rep, QueryParamsMap(), &onPut);
     }
 }
 
@@ -363,7 +366,7 @@ void onGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, cons
 
             std::cout << "\ton-off: " << mylight.m_on_off << std::endl;
 
-            putLightRepresentation(curResource);
+            postLightRepresentation(curResource);
         }
         else
         {
@@ -714,9 +717,9 @@ int main(int argc, char *argv[])
         cv.wait(lock);
 
     }
-    catch (OCException &e)
+    catch (const OCException &e)
     {
-        oclog() << "Exception in main: " << e.what();
+        std::cout << "Exception in main: " << e.what();
     }
 
     return 0;