Fix for following issues.
authorjyong2.kim <jyong2.kim@samsung.com>
Thu, 16 Apr 2015 04:35:14 +0000 (13:35 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 16 Apr 2015 06:06:15 +0000 (06:06 +0000)
[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>
service/notification-manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp

index 08dc41a..64fabc5 100755 (executable)
@@ -317,14 +317,32 @@ int main(int argc , char *argv[])
     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);