浏览代码

making client more conformant, relates to #420

Stasik0 9 年之前
父节点
当前提交
1662270c7a
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 11 1
      src/client/ua_client.c
  2. 3 2
      tools/amalgamate.py

+ 11 - 1
src/client/ua_client.c

@@ -29,6 +29,7 @@ struct UA_Client {
     UA_UserTokenPolicy token;
     UA_UserTokenPolicy token;
     UA_NodeId sessionId;
     UA_NodeId sessionId;
     UA_NodeId authenticationToken;
     UA_NodeId authenticationToken;
+    UA_UInt32 requestHandle;
     
     
 #ifdef ENABLE_SUBSCRIPTIONS
 #ifdef ENABLE_SUBSCRIPTIONS
     UA_Int32 monitoredItemHandles;
     UA_Int32 monitoredItemHandles;
@@ -71,6 +72,7 @@ void UA_Client_init(UA_Client* client, UA_ClientConfig config, UA_Logger logger)
     client->requestId = 0;
     client->requestId = 0;
 
 
     UA_NodeId_init(&client->authenticationToken);
     UA_NodeId_init(&client->authenticationToken);
+    client->requestHandle = 0;
 
 
     client->logger = logger;
     client->logger = logger;
     client->config = config;
     client->config = config;
@@ -280,13 +282,21 @@ static void synchronousRequest(UA_Client *client, void *request, const UA_DataTy
         return;
         return;
     }
     }
 
 
-    /* Copy authenticationToken token to request header */
+    /* HANDLING REQUEST HEADER PARAMETERS */
     typedef struct {
     typedef struct {
         UA_RequestHeader requestHeader;
         UA_RequestHeader requestHeader;
     } headerOnlyRequest;
     } headerOnlyRequest;
     /* The cast is valid, since all requests start with a requestHeader */
     /* The cast is valid, since all requests start with a requestHeader */
+
+    /* Copy authenticationToken token to request header */
     UA_NodeId_copy(&client->authenticationToken, &((headerOnlyRequest*)request)->requestHeader.authenticationToken);
     UA_NodeId_copy(&client->authenticationToken, &((headerOnlyRequest*)request)->requestHeader.authenticationToken);
 
 
+    ((headerOnlyRequest*)request)->requestHeader.timestamp = UA_DateTime_now();
+
+    ((headerOnlyRequest*)request)->requestHeader.requestHandle = ++client->requestHandle;
+
+    /*/HANDLING REQUEST HEADER PARAMETERS */
+
     /* Send the request */
     /* Send the request */
     UA_UInt32 requestId = ++client->requestId;
     UA_UInt32 requestId = ++client->requestId;
     retval = UA_SecureChannel_sendBinaryMessage(&client->channel, requestId,
     retval = UA_SecureChannel_sendBinaryMessage(&client->channel, requestId,

+ 3 - 2
tools/amalgamate.py

@@ -24,7 +24,7 @@ includes = []
 print ("Starting amalgamating file "+ args.outfile)
 print ("Starting amalgamating file "+ args.outfile)
 
 
 file = io.open(args.outfile, 'w')
 file = io.open(args.outfile, 'w')
-file.write(u'''/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES 
+file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES 
  * visit http://open62541.org/ for information about this software
  * visit http://open62541.org/ for information about this software
  * Git-Revision: %s
  * Git-Revision: %s
  */
  */
@@ -42,7 +42,8 @@ file.write(u'''/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN6
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  * details.
  * details.
- */\n\n''' % args.version)
+ */\n\n
+ """ % args.version)
 
 
 if not is_c:
 if not is_c:
     file.write(u'''#ifndef %s
     file.write(u'''#ifndef %s