Explorar el Código

Implemented UA_Client_getEndpoints function, relates to #313

Stasik0 hace 9 años
padre
commit
fcf6e55fa3
Se han modificado 2 ficheros con 10 adiciones y 1 borrados
  1. 1 1
      examples/client.c
  2. 9 0
      src/client/ua_client.c

+ 1 - 1
examples/client.c

@@ -38,7 +38,7 @@ int main(int argc, char *argv[]) {
 
     printf("%i endpoints found\n", (int)endpointArraySize);
     for(size_t i=0;i<endpointArraySize;i++){
-        printf("SecurityPolicyUri of endpoint %i is %.*s\n", (int)i, (int)endpointArray[i].securityPolicyUri.length, endpointArray[i].securityPolicyUri.data);
+        printf("URL of endpoint %i is %.*s\n", (int)i, (int)endpointArray[i].endpointUrl.length, endpointArray[i].endpointUrl.data);
     }
 
     //cleanup array of enpoints

+ 9 - 0
src/client/ua_client.c

@@ -343,6 +343,9 @@ static UA_StatusCode GetEndpoints(UA_Client *client, size_t* endpointDescription
     request.requestHeader.authenticationToken = client->authenticationToken;
     request.requestHeader.timestamp = UA_DateTime_now();
     request.requestHeader.timeoutHint = 10000;
+    
+    request.endpointUrl = client->endpointUrl; //here we assume the endpointUrl is on the stack
+    
     //no filter for endpoints
     request.profileUrisSize = 0;
 
@@ -516,6 +519,12 @@ UA_StatusCode UA_client_getEndpoints(UA_Client *client, UA_ConnectClientConnecti
         goto cleanup;
     }
 
+    client->endpointUrl = UA_STRING_ALLOC(serverUrl);
+    if(client->endpointUrl.data == NULL) {
+        retval = UA_STATUSCODE_BADOUTOFMEMORY;
+        goto cleanup;
+    }
+    
     client->connection.localConf = client->config.localConnectionConfig;
     retval = HelAckHandshake(client);
     if(retval == UA_STATUSCODE_GOOD)