Modify Notification Consumer Example
authorYounghyunJoo <yh_.joo@samsung.com>
Fri, 2 Sep 2016 04:05:44 +0000 (13:05 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 2 Sep 2016 09:35:13 +0000 (09:35 +0000)
- After deciding to remove discovry callback, discovery info is notified throgh the Provider Changed CallBack.
- we modify example code to possible to check its functionality.

Change-Id: I36af6597fa15b31d5665f2e4a0c4db2c11a8319c
Signed-off-by: YounghyunJoo <yh_.joo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11315
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/examples/linux/notificationconsumer.c

index 7960996..098020a 100644 (file)
@@ -50,13 +50,6 @@ FILE* server_fopen(const char *path, const char *mode)
     return fopen("oic_ns_provider_db.dat", mode);
 }
 
-void onDiscoverNotification(NSProvider * provider)
-{
-    printf("notification resource discovered\n");
-    printf("subscribe result %d\n", NSSubscribe(provider));
-    printf("startSubscribing\n");
-}
-
 void printProviderTopicList(NSProvider *provider)
 {
     printf("printProviderTopicList\n");
@@ -76,7 +69,13 @@ void onProviderChanged(NSProvider * provider, NSProviderState response)
     printf("Provider changed: %d\n", response);
     printf("subscribed provider Id : %s\n", provider->providerId);
 
-    if (response == NS_TOPIC)
+    if (response == NS_DISCOVERED)
+    {
+        printf("notification resource discovered\n");
+        printf("subscribe result %d\n", NSSubscribe(provider));
+        printf("startSubscribing\n");
+
+    } else if (response == NS_TOPIC)
     {
         printf ("Provider Topic Updated\n");