X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fexamples%2Fsimpleclient.cpp;h=e43618a79691ef5378cc724df32d5b0e7e63571e;hb=17c68b2fd1e74586f85e552eeab4e32dc121f8a0;hp=bb7620cd423595ef3591338daca6557bcdac2e75;hpb=8c01dff2c5bc5496f7dc1632c498943ec6ecb015;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/examples/simpleclient.cpp b/resource/examples/simpleclient.cpp index bb7620c..e43618a 100644 --- a/resource/examples/simpleclient.cpp +++ b/resource/examples/simpleclient.cpp @@ -59,13 +59,22 @@ int observe_count() return ++oc; } -void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, +void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& rep, const int& eCode, const int& sequenceNumber) { try { - if(eCode == OC_STACK_OK) + if(eCode == OC_STACK_OK && sequenceNumber != OC_OBSERVE_NO_OPTION) { + if(sequenceNumber == OC_OBSERVE_REGISTER) + { + std::cout << "Observe registration action is successful" << std::endl; + } + else if(sequenceNumber == OC_OBSERVE_DEREGISTER) + { + std::cout << "Observe De-registration action is successful" << std::endl; + } + std::cout << "OBSERVE RESULT:"< 10) + if(observe_count() == 11) { std::cout<<"Cancelling Observe..."<cancelObserve(); @@ -89,8 +98,15 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, } else { - std::cout << "onObserve Response error: " << eCode << std::endl; - std::exit(-1); + if(sequenceNumber == OC_OBSERVE_NO_OPTION) + { + std::cout << "Observe registration or de-registration action is failed" << std::endl; + } + else + { + std::cout << "onObserve Response error: " << eCode << std::endl; + std::exit(-1); + } } } catch(std::exception& e) @@ -100,7 +116,8 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, } -void onPost2(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onPost2(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& rep, const int eCode) { try { @@ -145,7 +162,8 @@ void onPost2(const HeaderOptions& headerOptions, const OCRepresentation& rep, co } -void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onPost(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& rep, const int eCode) { try { @@ -214,7 +232,7 @@ void postLightRepresentation(std::shared_ptr resource) } // callback handler on PUT request -void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { try { @@ -265,7 +283,7 @@ void putLightRepresentation(std::shared_ptr resource) } // Callback handler on GET request -void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) +void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { try { @@ -412,7 +430,7 @@ void checkObserverValue(int value) } } -static FILE* client_open(const char *path, const char *mode) +static FILE* client_open(const char* /*path*/, const char *mode) { return fopen("./oic_svr_db_client.json", mode); }