Procházet zdrojové kódy

Merge pull request #530 from StalderT/patch-1

modify UA_Client_Subscriptions_manuallySendPublishRequest to return status
Sten Grüner před 9 roky
rodič
revize
af31673318

+ 1 - 1
include/ua_client_highlevel.h

@@ -275,7 +275,7 @@ UA_Client_Subscriptions_new(UA_Client *client, UA_SubscriptionSettings settings,
 UA_StatusCode UA_EXPORT
 UA_Client_Subscriptions_remove(UA_Client *client, UA_UInt32 subscriptionId);
 
-void UA_EXPORT UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client);
+UA_StatusCode UA_EXPORT UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client);
 
 UA_StatusCode UA_EXPORT
 UA_Client_Subscriptions_addMonitoredItem(UA_Client *client, UA_UInt32 subscriptionId,

+ 6 - 2
src/client/ua_client_highlevel_subscriptions.c

@@ -274,7 +274,10 @@ UA_Client_processPublishRx(UA_Client *client, UA_PublishResponse response) {
     return response.moreNotifications;
 }
 
-void UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client) {
+UA_StatusCode UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client) {
+    if (client->state == UA_CLIENTSTATE_ERRORED){
+        return UA_STATUSCODE_BADSERVERNOTCONNECTED;
+    }
     UA_Boolean moreNotifications = UA_TRUE;
     do {
         UA_PublishRequest request;
@@ -288,7 +291,7 @@ void UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client) {
             request.subscriptionAcknowledgements = UA_malloc(sizeof(UA_SubscriptionAcknowledgement) *
                                                              request.subscriptionAcknowledgementsSize);
             if(!request.subscriptionAcknowledgements)
-                return;
+                return UA_STATUSCODE_GOOD;
         }
         
         int index = 0 ;
@@ -307,4 +310,5 @@ void UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client) {
         UA_PublishResponse_deleteMembers(&response);
         UA_PublishRequest_deleteMembers(&request);
     } while(moreNotifications == UA_TRUE);
+    return UA_STATUSCODE_GOOD;
 }