Modify Callback function in cpp wrapper for Notification Service.
[platform/upstream/iotivity.git] / service / notification / cpp-wrapper / examples / linux / notificationserviceconsumer.cpp
index c2f8fea..fe2af59 100755 (executable)
@@ -54,11 +54,12 @@ void onDiscoverNotificationCb(OIC::Service::NSProvider *provider)
     std::cout << "startSubscribing" << std::endl;\r
 }\r
 \r
-void onSubscriptionAcceptedCb(OIC::Service::NSProvider *provider)\r
+void onProviderChangedCb(OIC::Service::NSProvider *provider,OIC::Service::NSResponse response)\r
 {\r
     std::cout << "Subscription accepted" << std::endl;\r
     std::cout << "subscribed provider Id : " << provider->getProviderId() << std::endl;\r
-    provider->setListener(onNotificationPostedCb, onNotificationSyncCb);\r
+    if(response == OIC::Service::NSResponse::ALLOW)\r
+        provider->setListener(onNotificationPostedCb, onNotificationSyncCb);\r
 }\r
 \r
 void *OCProcessThread(void *ptr)\r
@@ -91,7 +92,7 @@ int main(void)
 \r
     NSConsumerService::ConsumerConfig cfg;\r
     cfg.m_discoverCb = onDiscoverNotificationCb;\r
-    cfg.m_acceptedCb = onSubscriptionAcceptedCb;\r
+    cfg.m_changedCb = onProviderChangedCb;\r
 \r
     pthread_create(&OCThread, NULL, OCProcessThread, NULL);\r
 \r