浏览代码

Client: Reorder client config definitions; small cleanup

Julius Pfrommer 6 年之前
父节点
当前提交
07c1ba184b
共有 3 个文件被更改,包括 37 次插入70 次删除
  1. 4 11
      include/ua_client.h
  2. 27 53
      include/ua_client_config.h
  3. 6 6
      plugins/ua_config_default.c

+ 4 - 11
include/ua_client.h

@@ -382,13 +382,6 @@ UA_Client_Service_queryNext(UA_Client *client,
  * be made without waiting for a response first. Responess may come in a
  * different ordering. */
 
-/* Listen on the network and process arriving asynchronous responses in the
- * background. Internal housekeeping and subscription management is done as
- * well. */
-
-/*UA_StatusCode UA_EXPORT
-UA_Client_runAsync(UA_Client *client, UA_UInt16 timeout);*/
-
 /* Use the type versions of this method. See below. However, the general
  * mechanism of async service calls is explained here.
  *
@@ -416,14 +409,14 @@ __UA_Client_AsyncService(UA_Client *client, const void *request,
                          const UA_DataType *responseType,
                          void *userdata, UA_UInt32 *requestId);
 
-/* For async connecting
- * */
 UA_StatusCode UA_EXPORT
 UA_Client_sendAsyncRequest(UA_Client *client, const void *request,
         const UA_DataType *requestType, UA_ClientAsyncServiceCallback callback,
-const UA_DataType *responseType, void *userdata, UA_UInt32 *requestId);
-
+        const UA_DataType *responseType, void *userdata, UA_UInt32 *requestId);
 
+/* Listen on the network and process arriving asynchronous responses in the
+ * background. Internal housekeeping and subscription management is done as
+ * well. */
 UA_StatusCode UA_EXPORT
 UA_Client_run_iterate(UA_Client *client, UA_UInt16 timeout);
 

+ 27 - 53
include/ua_client_config.h

@@ -45,15 +45,16 @@ typedef enum {
     UA_CLIENTSTATE_SESSION_RENEWED       /* A session with the server is open (renewed) */
 } UA_ClientState;
 
-
 struct UA_Client;
 typedef struct UA_Client UA_Client;
 
 typedef void (*UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata,
         UA_UInt32 requestId, void *response);
-/*
+
+/**
  * Repeated Callbacks
- * ------------------ */
+ * ^^^^^^^^^^^^^^^^^^ */
+
 typedef void (*UA_ClientCallback)(UA_Client *client, void *data);
 
 UA_StatusCode
@@ -67,26 +68,6 @@ UA_Client_changeRepeatedCallbackInterval(UA_Client *Client,
 UA_StatusCode UA_Client_removeRepeatedCallback(UA_Client *Client,
         UA_UInt64 callbackId);
 
-/**
- * Client Lifecycle callback
- * ^^^^^^^^^^^^^^^^^^^^^^^^^ */
-
-typedef void (*UA_ClientStateCallback)(UA_Client *client, UA_ClientState clientState);
-
-/**
- * Subscription Inactivity callback
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
-
-#ifdef UA_ENABLE_SUBSCRIPTIONS
-typedef void (*UA_SubscriptionInactivityCallback)(UA_Client *client, UA_UInt32 subscriptionId, void *subContext);
-#endif
-
-/**
- * Inactivity callback
- * ^^^^^^^^^^^^^^^^^^^ */
-
-typedef void (*UA_InactivityCallback)(UA_Client *client);
-
 /**
  * Client Configuration Data
  * ^^^^^^^^^^^^^^^^^^^^^^^^^ */
@@ -97,6 +78,8 @@ typedef struct UA_ClientConfig {
                                         to be renewed) */
     UA_Logger logger;
     UA_ConnectionConfig localConnectionConfig;
+
+    /* Callbacks for async connection handshakes */
     UA_ConnectClientConnection connectionFunc;
     UA_ConnectClientConnection initConnectionFunc;
     UA_ClientCallback pollConnectionFunc;
@@ -105,43 +88,34 @@ typedef struct UA_ClientConfig {
     size_t customDataTypesSize;
     const UA_DataType *customDataTypes;
 
-    /* Callback function */
-    UA_ClientStateCallback stateCallback;
-#ifdef UA_ENABLE_SUBSCRIPTIONS
-    /**
-     * When outStandingPublishRequests is greater than 0,
-     * the server automatically create publishRequest when
-     * UA_Client_runAsync is called. If the client don't receive
-     * a publishResponse after :
-     *     (sub->publishingInterval * sub->maxKeepAliveCount) +
-     *     client->config.timeout)
-     * then, the client call subscriptionInactivityCallback
-     * The connection can be closed, this in an attempt to
-     * recreate a healthy connection. */
-    UA_SubscriptionInactivityCallback subscriptionInactivityCallback;
-#endif
+    /* Callback for state changes */
+    void (*stateCallback)(UA_Client *client, UA_ClientState clientState);
+
+   /* Connectivity check interval in ms.
+    * 0 = background task disabled */
+    UA_UInt32 connectivityCheckInterval;
 
-    /** 
-     * When connectivityCheckInterval is greater than 0,
-     * every connectivityCheckInterval (in ms), a async read request
-     * is performed on the server. inactivityCallback is called
-     * when the client receive no response for this read request
-     * The connection can be closed, this in an attempt to
-     * recreate a healthy connection. */
-    UA_InactivityCallback inactivityCallback;
+    /* When connectivityCheckInterval is greater than 0, every
+     * connectivityCheckInterval (in ms), a async read request is performed on
+     * the server. inactivityCallback is called when the client receive no
+     * response for this read request The connection can be closed, this in an
+     * attempt to recreate a healthy connection. */
+    void (*inactivityCallback)(UA_Client *client);
 
     void *clientContext;
 
 #ifdef UA_ENABLE_SUBSCRIPTIONS
-    /* number of PublishResponse standing in the sever */
-    /* 0 = background task disabled                    */
+    /* Number of PublishResponse queued up in the server */
     UA_UInt16 outStandingPublishRequests;
-#endif
 
-   /**
-     * connectivity check interval in ms
-     * 0 = background task disabled */
-    UA_UInt32 connectivityCheckInterval;
+    /* If the client does not receive a PublishResponse after the defined delay
+     * of ``(sub->publishingInterval * sub->maxKeepAliveCount) +
+     * client->config.timeout)``, then subscriptionInactivityCallback is called
+     * for the subscription.. */
+    void (*subscriptionInactivityCallback)(UA_Client *client,
+                                           UA_UInt32 subscriptionId,
+                                           void *subContext);
+#endif
 } UA_ClientConfig;
 
 _UA_END_DECLS

+ 6 - 6
plugins/ua_config_default.c

@@ -679,17 +679,17 @@ const UA_ClientConfig UA_ClientConfig_default = {
     UA_ClientConnectionTCP, /* .connectionFunc (for sync connection) */
     UA_ClientConnectionTCP_init, /* .initConnectionFunc (for async client) */
     UA_ClientConnectionTCP_poll_callback, /* .pollConnectionFunc (for async connection) */
-    0, /* .customDataTypesSize */
+    0,    /* .customDataTypesSize */
     NULL, /* .customDataTypes */
 
     NULL, /* .stateCallback */
-#ifdef UA_ENABLE_SUBSCRIPTIONS
-    NULL, /* .subscriptionInactivityCallback */
-#endif
+    0,    /* .connectivityCheckInterval */
+
     NULL, /* .inactivityCallback */
     NULL, /* .clientContext */
+
 #ifdef UA_ENABLE_SUBSCRIPTIONS
-    10, /* .outStandingPublishRequests */
+    10,  /* .outStandingPublishRequests */
+    NULL /* .subscriptionInactivityCallback */
 #endif
-    0 /* .connectivityCheckInterval */
 };