Modify notificationconsumer example for MQ support test
authorYounghyunJoo <yh_.joo@samsung.com>
Thu, 24 Nov 2016 06:45:48 +0000 (15:45 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 5 Dec 2016 07:00:50 +0000 (07:00 +0000)
- add logic to test MQ subscrition.

Change-Id: Iaef04b5d38498b3f1a4a77a9a8c0677a587119f2
Signed-off-by: YounghyunJoo <yh_.joo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14735
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Chihyun Cho <ch79.cho@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification/examples/linux/notificationconsumer.c
service/notification/src/consumer/NSConsumerMQPlugin.c

index bef1e20..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];
@@ -169,6 +170,9 @@ int main(void)
         printf("4. Select Topics\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");
@@ -250,6 +254,19 @@ int main(void)
                 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");
index 283f10a..ef5a1bc 100644 (file)
@@ -72,7 +72,13 @@ void NSHandleMQSubscription(NSMQTopicAddress * topicAddr)
                         NSOICFree(topicAddr->serverAddr);
                         NSOICFree(topicAddr->topicName);
                     });
-    OCStackResult ret = NSInvokeRequest(NULL, OC_REST_GET, addr, serverUri, NULL,
+
+    char requestUri[100] = "coap+tcp://";
+    OICStrcat(requestUri, strlen(requestUri)+strlen(serverUri)+1, serverUri);
+    OICStrcat(requestUri, strlen(requestUri)+ strlen("/oic/ps") + 1, "/oic/ps");
+    NS_LOG_V(DEBUG, "requestUri = %s", requestUri);
+
+    OCStackResult ret = NSInvokeRequest(NULL, OC_REST_GET, addr, requestUri, NULL,
                       NSConsumerIntrospectMQTopic, topicName, OICFree, CT_DEFAULT);
     NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(NSOCResultToSuccess(ret) == true ? (void *)1 : NULL,
                    {