[IOT-459] [NM] NM Sample consumer and provider app doesnot handle invalid menu option properly
[IOT-460] [NM] NM Sample consumer App does not handle several observe request successfully and Application Crashes
Change-Id: I7d13109d0724ac2074b4d4b32065dfee183746d0
Signed-off-by: jyong2.kim <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/750
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
OCPlatform::Configure(cfg);
std::cout << "Created Platform..." << std::endl;
+
+ g_curResource = NULL;
+
findResourceCandidate();
while (1)
{
+ sleep(2);
+ if(g_curResource == NULL)
+ {
+ continue;
+ }
PRINT();
+ in = 0;
std::cin >> in;
- switch (in)
+
+ if(std::cin.fail())
+ {
+ std::cin.clear();
+ std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
+ std::cout << "Invalid input type, please try again" << std::endl;
+ continue;
+ }
+
+ switch ((int)in)
{
case OBSERVE:
startObserve(g_curResource);