Browse Source

Also add client to monitoredEvent callback

Stefan Profanter 6 years ago
parent
commit
3af3d9d969

+ 13 - 0
CHANGELOG

@@ -1,6 +1,19 @@
 This changelog reports changes to the public API. Internal refactorings and bug
 This changelog reports changes to the public API. Internal refactorings and bug
 fixes are not reported here.
 fixes are not reported here.
 
 
+2018-02-05 pro <profanter at fortiss.org>
+
+ * Also pass client to monitoredItem/Events callback
+
+   The UA_MonitoredItemHandlingFunction and UA_MonitoredEventHandlingFunction
+   did not include a reference to the corresponding client used for the call of
+   processPublishResponse.
+   This now also allows to get the client context within the monitored item
+   handling function.
+
+   The API changes are detected by the type-matching in the compiler. So there
+   is little risk for bugs due to unaligned implementations.
+
 2017-09-07 jpfr <julius.pfrommer at web.de>
 2017-09-07 jpfr <julius.pfrommer at web.de>
 
 
  * Make Client Highlevel Interface consistent
  * Make Client Highlevel Interface consistent

+ 2 - 1
examples/tutorial_client_events.c

@@ -14,7 +14,8 @@ static void stopHandler(int sig) {
 #ifdef UA_ENABLE_SUBSCRIPTIONS
 #ifdef UA_ENABLE_SUBSCRIPTIONS
 
 
 static void
 static void
-handler_events(const UA_UInt32 monId, const size_t nEventFields,
+handler_events(UA_Client *client,
+               const UA_UInt32 monId, const size_t nEventFields,
                const UA_Variant *eventFields, void *context) {
                const UA_Variant *eventFields, void *context) {
     UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Notification");
     UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Notification");
 
 

+ 2 - 1
include/ua_client_highlevel.h

@@ -617,7 +617,8 @@ UA_Client_Subscriptions_addMonitoredItem(UA_Client *client, UA_UInt32 subscripti
 
 
 /* Monitored Events have different payloads from DataChanges. So they use a
 /* Monitored Events have different payloads from DataChanges. So they use a
  * different callback method signature. */
  * different callback method signature. */
-typedef void (*UA_MonitoredEventHandlingFunction)(const UA_UInt32 monId,
+typedef void (*UA_MonitoredEventHandlingFunction)(UA_Client *client,
+                                                  const UA_UInt32 monId,
                                                   const size_t nEventFields,
                                                   const size_t nEventFields,
                                                   const UA_Variant *eventFields,
                                                   const UA_Variant *eventFields,
                                                   void *context);
                                                   void *context);

+ 1 - 1
src/client/ua_client_highlevel_subscriptions.c

@@ -458,7 +458,7 @@ UA_Client_processPublishResponse(UA_Client *client, UA_PublishRequest *request,
                     continue;
                     continue;
                 }
                 }
 
 
-                mon->handler.eventHandler(mon->monitoredItemId, eventFieldList->eventFieldsSize,
+                mon->handler.eventHandler(client, mon->monitoredItemId, eventFieldList->eventFieldsSize,
                                           eventFieldList->eventFields, mon->handlerContext);
                                           eventFieldList->eventFields, mon->handlerContext);
             }
             }
         }
         }