// implemented from callback interface // ============================================================================================= void Subscription::newEvents(UaEventFieldLists& uaEventFieldList) { // get the number of notifications uint32_t noOfNotifications = uaEventFieldList.length(); logger_->debug("A total of %d notifications were received", noOfNotifications); // create the notifications vector<EventNotification> notifications; // fill the notifications for (uint32_t i=0; i < noOfNotifications; i++) { ClientHandle clientHandle = uaEventFieldList[i].ClientHandle; MonitoredItemsMap::const_iterator it = monitoredItemsMap_.find(clientHandle); // update the contents of the notification if (it != monitoredItemsMap_.end()) { EventNotification notification; notification.clientHandle = clientHandle; // update the event fields for (int32_t j=0; j < uaEventFieldList[i].NoOfEventFields; j++) notification.fields.push_back(Variant(uaEventFieldList[i].EventFields[j])); // add it to the vector of notifications for the callback notifications.push_back(notification); // log the notification logger_->debug(" - Notification %d:", int(i)); logger_->debug(notification.toString(" ", 25)); } } // call the callback interface clientInterface_->eventsReceived(notifications); }
// implemented from callback interface // ============================================================================================= void SubscriptionFactory::newEvents( OpcUa_UInt32 clientSubscriptionHandle, UaEventFieldLists& uaEventFieldList) { logger_->debug("Subscription %d received %d new events", clientSubscriptionHandle, uaEventFieldList.length()); // acquire the subscription for which the event was meant: Subscription* subscription = 0; Status acquireStatus = acquireExistingSubscription(clientSubscriptionHandle, subscription); if (acquireStatus.isGood()) { // update the session state subscription->newEvents(uaEventFieldList); // release the acquired session releaseSubscription(subscription); } else { logger_->warning("Unknown ClientSubscriptionHandle, discarding notification!"); } }