|
@@ -109,6 +109,26 @@ Service_ModifySubscription(UA_Server *server, UA_Session *session,
|
|
|
response->revisedMaxKeepAliveCount = sub->maxKeepAliveCount;
|
|
|
}
|
|
|
|
|
|
+static UA_THREAD_LOCAL UA_Boolean op_publishingEnabled;
|
|
|
+
|
|
|
+static void
|
|
|
+Operation_SetPublishingMode(UA_Server *Server, UA_Session *session,
|
|
|
+ UA_UInt32 *subscriptionId,
|
|
|
+ UA_StatusCode *result) {
|
|
|
+ UA_Subscription *sub =
|
|
|
+ UA_Session_getSubscriptionByID(session, *subscriptionId);
|
|
|
+ if(!sub) {
|
|
|
+ *result = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Reset the subscription lifetime */
|
|
|
+ sub->currentLifetimeCount = 0;
|
|
|
+
|
|
|
+ /* Set the publishing mode */
|
|
|
+ sub->publishingEnabled = op_publishingEnabled;
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
Service_SetPublishingMode(UA_Server *server, UA_Session *session,
|
|
|
const UA_SetPublishingModeRequest *request,
|
|
@@ -116,31 +136,12 @@ Service_SetPublishingMode(UA_Server *server, UA_Session *session,
|
|
|
UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
"Processing SetPublishingModeRequest", NULL);
|
|
|
|
|
|
- if(request->subscriptionIdsSize <= 0) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- size_t size = request->subscriptionIdsSize;
|
|
|
- response->results = (UA_StatusCode *)UA_Array_new(size, &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
- if(!response->results) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- response->resultsSize = size;
|
|
|
- for(size_t i = 0; i < size; ++i) {
|
|
|
- UA_Subscription *sub =
|
|
|
- UA_Session_getSubscriptionByID(session, request->subscriptionIds[i]);
|
|
|
- if(!sub) {
|
|
|
- response->results[i] = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(sub->publishingEnabled != request->publishingEnabled) {
|
|
|
- sub->publishingEnabled = request->publishingEnabled;
|
|
|
- sub->currentLifetimeCount = 0; /* Reset the subscription lifetime */
|
|
|
- }
|
|
|
- }
|
|
|
+ op_publishingEnabled = request->publishingEnabled;
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_Server_processServiceOperations(server, session,
|
|
|
+ (UA_ServiceOperation)Operation_SetPublishingMode,
|
|
|
+ &request->subscriptionIdsSize, &UA_TYPES[UA_TYPES_UINT32],
|
|
|
+ &response->resultsSize, &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
}
|
|
|
|
|
|
static void
|
|
@@ -196,18 +197,19 @@ setMonitoredItemSettings(UA_Server *server, UA_MonitoredItem *mon,
|
|
|
static const UA_String binaryEncoding = {sizeof("Default Binary")-1, (UA_Byte*)"Default Binary"};
|
|
|
/* static const UA_String xmlEncoding = {sizeof("Default Xml")-1, (UA_Byte*)"Default Xml"}; */
|
|
|
|
|
|
+/* Thread-local variables to pass additional arguments into the operation */
|
|
|
+static UA_THREAD_LOCAL UA_Subscription *op_sub;
|
|
|
+static UA_THREAD_LOCAL UA_TimestampsToReturn op_timestampsToReturn2;
|
|
|
+
|
|
|
static void
|
|
|
-Service_CreateMonitoredItems_single(UA_Server *server, UA_Session *session,
|
|
|
- UA_Subscription *sub,
|
|
|
- const UA_TimestampsToReturn timestampsToReturn,
|
|
|
- const UA_MonitoredItemCreateRequest *request,
|
|
|
- UA_MonitoredItemCreateResult *result) {
|
|
|
+Operation_CreateMonitoredItem(UA_Server *server, UA_Session *session,
|
|
|
+ const UA_MonitoredItemCreateRequest *request,
|
|
|
+ UA_MonitoredItemCreateResult *result) {
|
|
|
/* Make an example read to get errors in the itemToMonitor. Allow return
|
|
|
* codes "good" and "uncertain", as well as a list of statuscodes that might
|
|
|
* be repaired inside the data source. */
|
|
|
- UA_DataValue v;
|
|
|
- UA_DataValue_init(&v);
|
|
|
- Service_Read_single(server, session, timestampsToReturn, &request->itemToMonitor, &v);
|
|
|
+ UA_DataValue v = UA_Server_readWithSession(server, session, &request->itemToMonitor,
|
|
|
+ op_timestampsToReturn2);
|
|
|
if(v.hasStatus && (v.status >> 30) > 1 &&
|
|
|
v.status != UA_STATUSCODE_BADRESOURCEUNAVAILABLE &&
|
|
|
v.status != UA_STATUSCODE_BADCOMMUNICATIONERROR &&
|
|
@@ -246,13 +248,13 @@ Service_CreateMonitoredItems_single(UA_Server *server, UA_Session *session,
|
|
|
MonitoredItem_delete(server, newMon);
|
|
|
return;
|
|
|
}
|
|
|
- newMon->subscription = sub;
|
|
|
+ newMon->subscription = op_sub;
|
|
|
newMon->attributeID = request->itemToMonitor.attributeId;
|
|
|
- newMon->itemId = ++(sub->lastMonitoredItemId);
|
|
|
- newMon->timestampsToReturn = timestampsToReturn;
|
|
|
+ newMon->itemId = ++(op_sub->lastMonitoredItemId);
|
|
|
+ newMon->timestampsToReturn = op_timestampsToReturn2;
|
|
|
setMonitoredItemSettings(server, newMon, request->monitoringMode,
|
|
|
&request->requestedParameters);
|
|
|
- LIST_INSERT_HEAD(&sub->monitoredItems, newMon, listEntry);
|
|
|
+ LIST_INSERT_HEAD(&op_sub->monitoredItems, newMon, listEntry);
|
|
|
|
|
|
/* Create the first sample */
|
|
|
if(request->monitoringMode == UA_MONITORINGMODE_REPORTING)
|
|
@@ -273,42 +275,36 @@ Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
|
|
|
"Processing CreateMonitoredItemsRequest", NULL);
|
|
|
|
|
|
/* Check if the timestampstoreturn is valid */
|
|
|
- if(request->timestampsToReturn > UA_TIMESTAMPSTORETURN_NEITHER) {
|
|
|
+ op_timestampsToReturn2 = request->timestampsToReturn;
|
|
|
+ if(op_timestampsToReturn2 > UA_TIMESTAMPSTORETURN_NEITHER) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADTIMESTAMPSTORETURNINVALID;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- UA_Subscription *sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
- if(!sub) {
|
|
|
+ /* Find the subscription */
|
|
|
+ op_sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
+ if(!op_sub) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
/* Reset the subscription lifetime */
|
|
|
- sub->currentLifetimeCount = 0;
|
|
|
- if(request->itemsToCreateSize <= 0) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
|
|
|
- return;
|
|
|
- }
|
|
|
+ op_sub->currentLifetimeCount = 0;
|
|
|
|
|
|
- response->results = (UA_MonitoredItemCreateResult *)UA_Array_new(request->itemsToCreateSize,
|
|
|
- &UA_TYPES[UA_TYPES_MONITOREDITEMCREATERESULT]);
|
|
|
- if(!response->results) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
- return;
|
|
|
- }
|
|
|
- response->resultsSize = request->itemsToCreateSize;
|
|
|
-
|
|
|
- for(size_t i = 0; i < request->itemsToCreateSize; ++i)
|
|
|
- Service_CreateMonitoredItems_single(server, session, sub, request->timestampsToReturn,
|
|
|
- &request->itemsToCreate[i], &response->results[i]);
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_Server_processServiceOperations(server, session,
|
|
|
+ (UA_ServiceOperation)Operation_CreateMonitoredItem,
|
|
|
+ &request->itemsToCreateSize, &UA_TYPES[UA_TYPES_MONITOREDITEMCREATEREQUEST],
|
|
|
+ &response->resultsSize, &UA_TYPES[UA_TYPES_MONITOREDITEMCREATERESULT]);
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
-Service_ModifyMonitoredItems_single(UA_Server *server, UA_Session *session, UA_Subscription *sub,
|
|
|
- const UA_MonitoredItemModifyRequest *request,
|
|
|
- UA_MonitoredItemModifyResult *result) {
|
|
|
- UA_MonitoredItem *mon = UA_Subscription_getMonitoredItem(sub, request->monitoredItemId);
|
|
|
+Operation_ModifyMonitoredItem(UA_Server *server, UA_Session *session,
|
|
|
+ const UA_MonitoredItemModifyRequest *request,
|
|
|
+ UA_MonitoredItemModifyResult *result) {
|
|
|
+ /* Get the MonitoredItem */
|
|
|
+ UA_MonitoredItem *mon =
|
|
|
+ UA_Subscription_getMonitoredItem(op_sub, request->monitoredItemId);
|
|
|
if(!mon) {
|
|
|
result->statusCode = UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
|
|
|
return;
|
|
@@ -326,38 +322,51 @@ void Service_ModifyMonitoredItems(UA_Server *server, UA_Session *session,
|
|
|
UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
"Processing ModifyMonitoredItemsRequest", NULL);
|
|
|
|
|
|
- /* check if the timestampstoreturn is valid */
|
|
|
+ /* Check if the timestampstoreturn is valid */
|
|
|
if(request->timestampsToReturn > UA_TIMESTAMPSTORETURN_NEITHER) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADTIMESTAMPSTORETURNINVALID;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
/* Get the subscription */
|
|
|
- UA_Subscription *sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
- if(!sub) {
|
|
|
+ op_sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
+ if(!op_sub) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
/* Reset the subscription lifetime */
|
|
|
- sub->currentLifetimeCount = 0;
|
|
|
- if(request->itemsToModifySize <= 0) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
|
|
|
- return;
|
|
|
- }
|
|
|
+ op_sub->currentLifetimeCount = 0;
|
|
|
|
|
|
- response->results = (UA_MonitoredItemModifyResult *)UA_Array_new(request->itemsToModifySize,
|
|
|
- &UA_TYPES[UA_TYPES_MONITOREDITEMMODIFYRESULT]);
|
|
|
- if(!response->results) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_Server_processServiceOperations(server, session,
|
|
|
+ (UA_ServiceOperation)Operation_ModifyMonitoredItem,
|
|
|
+ &request->itemsToModifySize, &UA_TYPES[UA_TYPES_MONITOREDITEMMODIFYREQUEST],
|
|
|
+ &response->resultsSize, &UA_TYPES[UA_TYPES_MONITOREDITEMMODIFYRESULT]);
|
|
|
+}
|
|
|
+
|
|
|
+/* Get the additional argument into the operation */
|
|
|
+static UA_THREAD_LOCAL UA_MonitoringMode op_monitoringMode;
|
|
|
+
|
|
|
+static void
|
|
|
+Operation_SetMonitoringMode(UA_Server *server, UA_Session *session,
|
|
|
+ UA_UInt32 *monitoredItemId,
|
|
|
+ UA_StatusCode *result) {
|
|
|
+ UA_MonitoredItem *mon =
|
|
|
+ UA_Subscription_getMonitoredItem(op_sub, *monitoredItemId);
|
|
|
+ if(!mon) {
|
|
|
+ *result = UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
|
|
|
return;
|
|
|
}
|
|
|
- response->resultsSize = request->itemsToModifySize;
|
|
|
|
|
|
- for(size_t i = 0; i < request->itemsToModifySize; ++i)
|
|
|
- Service_ModifyMonitoredItems_single(server, session, sub, &request->itemsToModify[i],
|
|
|
- &response->results[i]);
|
|
|
+ if(mon->monitoringMode == op_monitoringMode)
|
|
|
+ return;
|
|
|
|
|
|
+ mon->monitoringMode = op_monitoringMode;
|
|
|
+ if(mon->monitoringMode == UA_MONITORINGMODE_REPORTING)
|
|
|
+ MonitoredItem_registerSampleCallback(server, mon);
|
|
|
+ else
|
|
|
+ MonitoredItem_unregisterSampleCallback(server, mon);
|
|
|
}
|
|
|
|
|
|
void Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
|
|
@@ -366,39 +375,22 @@ void Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
|
|
|
UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
"Processing SetMonitoringMode", NULL);
|
|
|
|
|
|
- UA_Subscription *sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
- if(!sub) {
|
|
|
+ /* Get the subscription */
|
|
|
+ op_sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
+ if(!op_sub) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(request->monitoredItemIdsSize == 0) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- response->results = (UA_StatusCode *)UA_Array_new(request->monitoredItemIdsSize, &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
- if(!response->results) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
- return;
|
|
|
- }
|
|
|
- response->resultsSize = request->monitoredItemIdsSize;
|
|
|
-
|
|
|
- for(size_t i = 0; i < response->resultsSize; ++i) {
|
|
|
- UA_MonitoredItem *mon =
|
|
|
- UA_Subscription_getMonitoredItem(sub, request->monitoredItemIds[i]);
|
|
|
- if(!mon) {
|
|
|
- response->results[i] = UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(request->monitoringMode == mon->monitoringMode)
|
|
|
- continue;
|
|
|
- mon->monitoringMode = request->monitoringMode;
|
|
|
- if(mon->monitoringMode == UA_MONITORINGMODE_REPORTING)
|
|
|
- MonitoredItem_registerSampleCallback(server, mon);
|
|
|
- else
|
|
|
- MonitoredItem_unregisterSampleCallback(server, mon);
|
|
|
- }
|
|
|
+ /* Reset the subscription lifetime */
|
|
|
+ op_sub->currentLifetimeCount = 0;
|
|
|
+
|
|
|
+ op_monitoringMode = request->monitoringMode;
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_Server_processServiceOperations(server, session,
|
|
|
+ (UA_ServiceOperation)Operation_SetMonitoringMode,
|
|
|
+ &request->monitoredItemIdsSize, &UA_TYPES[UA_TYPES_UINT32],
|
|
|
+ &response->resultsSize, &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
}
|
|
|
|
|
|
/* TODO: Unify with senderror in ua_server_binary.c */
|
|
@@ -427,10 +419,12 @@ Service_Publish(UA_Server *server, UA_Session *session,
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- UA_PublishResponseEntry *entry = (UA_PublishResponseEntry *)UA_malloc(sizeof(UA_PublishResponseEntry));
|
|
|
+ UA_PublishResponseEntry *entry =
|
|
|
+ (UA_PublishResponseEntry*)UA_malloc(sizeof(UA_PublishResponseEntry));
|
|
|
if(!entry) {
|
|
|
subscriptionSendError(session->channel, requestId,
|
|
|
- request->requestHeader.requestHandle, UA_STATUSCODE_BADOUTOFMEMORY);
|
|
|
+ request->requestHeader.requestHandle,
|
|
|
+ UA_STATUSCODE_BADOUTOFMEMORY);
|
|
|
return;
|
|
|
}
|
|
|
entry->requestId = requestId;
|
|
@@ -440,8 +434,9 @@ Service_Publish(UA_Server *server, UA_Session *session,
|
|
|
UA_PublishResponse_init(response);
|
|
|
response->responseHeader.requestHandle = request->requestHeader.requestHandle;
|
|
|
if(request->subscriptionAcknowledgementsSize > 0) {
|
|
|
- response->results = (UA_StatusCode *)UA_Array_new(request->subscriptionAcknowledgementsSize,
|
|
|
- &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
+ response->results = (UA_StatusCode*)
|
|
|
+ UA_Array_new(request->subscriptionAcknowledgementsSize,
|
|
|
+ &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
if(!response->results) {
|
|
|
UA_free(entry);
|
|
|
subscriptionSendError(session->channel, requestId,
|
|
@@ -464,7 +459,8 @@ Service_Publish(UA_Server *server, UA_Session *session,
|
|
|
continue;
|
|
|
}
|
|
|
/* Remove the acked transmission from the retransmission queue */
|
|
|
- response->results[i] = UA_Subscription_removeRetransmissionMessage(sub, ack->sequenceNumber);
|
|
|
+ response->results[i] =
|
|
|
+ UA_Subscription_removeRetransmissionMessage(sub, ack->sequenceNumber);
|
|
|
}
|
|
|
|
|
|
/* Queue the publish response */
|
|
@@ -485,6 +481,21 @@ Service_Publish(UA_Server *server, UA_Session *session,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void
|
|
|
+Operation_DeleteSubscription(UA_Server *server, UA_Session *session,
|
|
|
+ UA_UInt32 *subscriptionId, UA_StatusCode *result) {
|
|
|
+ *result = UA_Session_deleteSubscription(server, session, *subscriptionId);
|
|
|
+ if(*result == UA_STATUSCODE_GOOD) {
|
|
|
+ UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
+ "Subscription %u | Subscription deleted",
|
|
|
+ *subscriptionId);
|
|
|
+ } else {
|
|
|
+ UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
+ "Deleting Subscription with Id %u failed with error "
|
|
|
+ "code %s", *subscriptionId, UA_StatusCode_name(*result));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
|
|
|
const UA_DeleteSubscriptionsRequest *request,
|
|
@@ -492,41 +503,28 @@ Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
|
|
|
UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
"Processing DeleteSubscriptionsRequest", NULL);
|
|
|
|
|
|
- if(request->subscriptionIdsSize == 0) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
|
|
|
- return;
|
|
|
- }
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_Server_processServiceOperations(server, session,
|
|
|
+ (UA_ServiceOperation)Operation_DeleteSubscription,
|
|
|
+ &request->subscriptionIdsSize, &UA_TYPES[UA_TYPES_UINT32],
|
|
|
+ &response->resultsSize, &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
|
|
|
- response->results = (UA_StatusCode *)UA_malloc(sizeof(UA_StatusCode) * request->subscriptionIdsSize);
|
|
|
- if(!response->results) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
+ /* The session has at least one subscription */
|
|
|
+ if(LIST_FIRST(&session->serverSubscriptions))
|
|
|
return;
|
|
|
- }
|
|
|
- response->resultsSize = request->subscriptionIdsSize;
|
|
|
-
|
|
|
- for(size_t i = 0; i < request->subscriptionIdsSize; ++i) {
|
|
|
- response->results[i] = UA_Session_deleteSubscription(server, session, request->subscriptionIds[i]);
|
|
|
- if(response->results[i] == UA_STATUSCODE_GOOD) {
|
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session, "Subscription %u | "
|
|
|
- "Subscription deleted", request->subscriptionIds[i]);
|
|
|
- } else {
|
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session, "Deleting Subscription with Id "
|
|
|
- "%u failed with error code 0x%08x", request->subscriptionIds[i],
|
|
|
- response->results[i]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- /* Send dangling publish responses in a delayed callback if the last
|
|
|
+ /* Send remaining publish responses in a delayed callback if the last
|
|
|
* subscription was removed */
|
|
|
- if(LIST_FIRST(&session->serverSubscriptions))
|
|
|
- return;
|
|
|
- UA_NodeId *sessionToken = UA_NodeId_new();
|
|
|
- if(!sessionToken)
|
|
|
- return;
|
|
|
- UA_NodeId_copy(&session->authenticationToken, sessionToken);
|
|
|
- UA_Server_delayedCallback(server,
|
|
|
- (UA_ServerCallback)UA_Subscription_answerPublishRequestsNoSubscription,
|
|
|
- sessionToken);
|
|
|
+ UA_Server_delayedCallback(server, (UA_ServerCallback)
|
|
|
+ UA_Subscription_answerPublishRequestsNoSubscription,
|
|
|
+ session);
|
|
|
+}
|
|
|
+
|
|
|
+static void
|
|
|
+Operation_DeleteMonitoredItem(UA_Server *server, UA_Session *session,
|
|
|
+ UA_UInt32 *monitoredItemId,
|
|
|
+ UA_StatusCode *result) {
|
|
|
+ *result = UA_Subscription_deleteMonitoredItem(server, op_sub, *monitoredItemId);
|
|
|
}
|
|
|
|
|
|
void Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
|
|
@@ -535,32 +533,25 @@ void Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
|
|
|
UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
"Processing DeleteMonitoredItemsRequest", NULL);
|
|
|
|
|
|
- if(request->monitoredItemIdsSize == 0) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTHINGTODO;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
/* Get the subscription */
|
|
|
- UA_Subscription *sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
- if(!sub) {
|
|
|
+ op_sub = UA_Session_getSubscriptionByID(session, request->subscriptionId);
|
|
|
+ if(!op_sub) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
/* Reset the subscription lifetime */
|
|
|
- sub->currentLifetimeCount = 0;
|
|
|
- response->results = (UA_StatusCode *)UA_malloc(sizeof(UA_StatusCode) * request->monitoredItemIdsSize);
|
|
|
- if(!response->results) {
|
|
|
- response->responseHeader.serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
|
|
|
- return;
|
|
|
- }
|
|
|
- response->resultsSize = request->monitoredItemIdsSize;
|
|
|
+ op_sub->currentLifetimeCount = 0;
|
|
|
|
|
|
- for(size_t i = 0; i < request->monitoredItemIdsSize; ++i)
|
|
|
- response->results[i] = UA_Subscription_deleteMonitoredItem(server, sub, request->monitoredItemIds[i]);
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_Server_processServiceOperations(server, session,
|
|
|
+ (UA_ServiceOperation)Operation_DeleteMonitoredItem,
|
|
|
+ &request->monitoredItemIdsSize, &UA_TYPES[UA_TYPES_UINT32],
|
|
|
+ &response->resultsSize, &UA_TYPES[UA_TYPES_STATUSCODE]);
|
|
|
}
|
|
|
|
|
|
-void Service_Republish(UA_Server *server, UA_Session *session, const UA_RepublishRequest *request,
|
|
|
+void Service_Republish(UA_Server *server, UA_Session *session,
|
|
|
+ const UA_RepublishRequest *request,
|
|
|
UA_RepublishResponse *response) {
|
|
|
UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
"Processing RepublishRequest", NULL);
|
|
@@ -581,11 +572,13 @@ void Service_Republish(UA_Server *server, UA_Session *session, const UA_Republis
|
|
|
if(entry->message.sequenceNumber == request->retransmitSequenceNumber)
|
|
|
break;
|
|
|
}
|
|
|
- if(entry)
|
|
|
- response->responseHeader.serviceResult =
|
|
|
- UA_NotificationMessage_copy(&entry->message, &response->notificationMessage);
|
|
|
- else
|
|
|
+ if(!entry) {
|
|
|
response->responseHeader.serviceResult = UA_STATUSCODE_BADMESSAGENOTAVAILABLE;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ response->responseHeader.serviceResult =
|
|
|
+ UA_NotificationMessage_copy(&entry->message, &response->notificationMessage);
|
|
|
}
|
|
|
|
|
|
#endif /* UA_ENABLE_SUBSCRIPTIONS */
|