replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / examples / linux / notificationconsumer.c
index 679b113..8c14cd3 100644 (file)
@@ -35,6 +35,7 @@
 #define CLOUD_CONTEXT_VALUE 0x99
 
 char CLOUD_ADDRESS[100];
+char CLOUD_TOPIC[100];
 char CLOUD_AUTH_PROVIDER[100];
 char CLOUD_AUTH_CODE[100];
 char CLOUD_UID[100];
@@ -167,7 +168,11 @@ int main(void)
         printf("2. Stop Consumer\n");
         printf("3. Get Topics\n");
         printf("4. Select Topics\n");
-        printf("5. Exit\n");
+        printf("5. Cancel select Topics\n");
+        printf("0. Exit\n");
+#ifdef WITH_MQ
+        printf("11. Subscribe MQ Service\n");
+#endif
 #ifdef WITH_CLOUD
         printf("21. Enable Remote Service (after login)\n");
         printf("31. Cloud Signup\n");
@@ -231,9 +236,37 @@ int main(void)
                 }
                 break;
             case 5:
-                printf("5. Exit");
+                printf("5. Cancel select Topics\n");
+                NSTopicLL * iter = g_topicLL;
+                while (iter)
+                {
+                    iter->state = NS_TOPIC_UNSUBSCRIBED;
+                    iter = iter->next;
+                }
+
+                NSResult ret = NSConsumerUpdateTopicList(g_provider->providerId, g_topicLL);
+                if (ret != NS_OK)
+                {
+                    printf("Cancel select topic fail\n");
+                }
+                break;
+            case 0:
+                printf("0. Exit");
                 isExit = true;
                 break;
+#if WITH_MQ
+            case 11:
+                printf("11. Subscribe MQ Service\n");
+
+                printf("Remote Server Address: ");
+                input(CLOUD_ADDRESS);
+
+                printf("Topic[notification]: ");
+                input(CLOUD_TOPIC);
+
+                NSConsumerSubscribeMQService(CLOUD_ADDRESS, CLOUD_TOPIC);
+                break;
+#endif
 #ifdef WITH_CLOUD
             case 21:
                 printf("Enable Remote Service");
@@ -283,3 +316,4 @@ int main(void)
     }
     return 0;
 }
+