X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fresource-encapsulation%2Fexamples%2Flinux%2FSampleResourceServer.cpp;h=9e919b60e9464c0cd0b6b00c5a169f3c8dbaeaad;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=65b9cd61e706a659fb7074349f425809ba34a4b5;hpb=edcfc3d2329da7b914771c0dcff5f42c9b74fd93;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/resource-encapsulation/examples/linux/SampleResourceServer.cpp b/service/resource-encapsulation/examples/linux/SampleResourceServer.cpp index 65b9cd6..9e919b6 100644 --- a/service/resource-encapsulation/examples/linux/SampleResourceServer.cpp +++ b/service/resource-encapsulation/examples/linux/SampleResourceServer.cpp @@ -19,6 +19,7 @@ ******************************************************************/ #include "RCSResourceObject.h" +#include "RCSRequest.h" #include "OCPlatform.h" using namespace OC::OCPlatform; @@ -53,7 +54,7 @@ int processUserInput(int min, int max) { assert(min <= max); - int input; + int input = 0; std::cin >> input; @@ -102,7 +103,7 @@ void printAttributes(const RCSResourceAttributes& attrs) } } -RCSGetResponse requestHandlerForGet(const RCSRequest&, RCSResourceAttributes& attrs) +RCSGetResponse requestHandlerForGet(const RCSRequest & req, RCSResourceAttributes& attrs) { std::cout << "Received a Get request from Client" << std::endl; printAttributes(attrs); @@ -110,10 +111,21 @@ RCSGetResponse requestHandlerForGet(const RCSRequest&, RCSResourceAttributes& at { RCSResourceObject::LockGuard lock(g_resource); std::cout << "\nSending response to Client : " << std::endl; - printAttributes(g_resource->getAttributes()); + if (req.getInterface() == CUSTOM_INTERFACE) + { + auto attr = g_resource->getAttributes(); + static RCSByteString::DataType binval {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, + 0x9, 0x0, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; + attr["blob"] = RCSByteString {binval}; + printAttributes(attr); + return RCSGetResponse::create(attr); + } + else + { + printAttributes(g_resource->getAttributes()); + return RCSGetResponse::defaultAction(); + } } - - return RCSGetResponse::defaultAction(); } RCSSetResponse requestHandlerForSet(const RCSRequest&, RCSResourceAttributes& attrs) @@ -178,7 +190,7 @@ void runResourceTypeSelection(int resourceMode) std::cout << "========================================================\n"; int resourceType = processUserInput(RESOURCE_TEMP, RESOURCE_LIGHT); - DisplayControlMenuFunc displayMenuFunc; + DisplayControlMenuFunc displayMenuFunc = nullptr; std::string attrKey; switch (resourceType) @@ -264,7 +276,14 @@ int main(void) if (g_isPresenceStarted) { - stopPresence(); + try + { + stopPresence(); + } + catch(...) + { + std::cout << "presence stop fail" << std::endl; + } } }