Browse Source

Add client context to UA_Client

The client context is set in UA_ClientConfig and can be
retrieved using UA_Client_getContext().
Jannis Voelker 7 years ago
parent
commit
bcb30aa72d
3 changed files with 14 additions and 1 deletions
  1. 5 0
      include/ua_client.h
  2. 2 1
      plugins/ua_config_default.c
  3. 7 0
      src/client/ua_client.c

+ 5 - 0
include/ua_client.h

@@ -70,6 +70,7 @@ typedef struct UA_ClientConfig {
 
     /* Callback function */
     UA_ClientStateCallback stateCallback;
+    void *clientContext;
 } UA_ClientConfig;
 
 
@@ -81,6 +82,10 @@ UA_Client_new(UA_ClientConfig config);
 UA_ClientState UA_EXPORT
 UA_Client_getState(UA_Client *client);
 
+/* Get the client context */
+void UA_EXPORT *
+UA_Client_getContext(UA_Client *client);
+
 /* Reset a client */
 void UA_EXPORT
 UA_Client_reset(UA_Client *client);

+ 2 - 1
plugins/ua_config_default.c

@@ -458,7 +458,8 @@ const UA_ClientConfig UA_ClientConfig_default = {
 
     0, /* .customDataTypesSize */
     NULL, /*.customDataTypes */
-    NULL /*.stateCallback */
+    NULL, /*.stateCallback */
+    NULL  /*.clientContext */
 };
 
 /****************************************/

+ 7 - 0
src/client/ua_client.c

@@ -80,6 +80,13 @@ UA_Client_getState(UA_Client *client) {
     return client->state;
 }
 
+void *
+UA_Client_getContext(UA_Client *client) {
+    if(!client)
+        return NULL;
+    return client->config.clientContext;
+}
+
 /****************/
 /* Raw Services */
 /****************/