use of org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage in project milo by eclipse.
the class Subscription method returnStatusChangeNotification.
void returnStatusChangeNotification(ServiceRequest service, StatusCode status) {
StatusChangeNotification statusChange = new StatusChangeNotification(status, null);
UInteger sequenceNumber = uint(nextSequenceNumber());
NotificationMessage notificationMessage = new NotificationMessage(sequenceNumber, DateTime.now(), new ExtensionObject[] { ExtensionObject.encode(serializationContext, statusChange) });
ResponseHeader header = service.createResponseHeader();
PublishResponse response = new PublishResponse(header, subscriptionId, new UInteger[0], false, notificationMessage, service.attr(KEY_ACK_RESULTS).get(), new DiagnosticInfo[0]);
service.setResponse(response);
logger.debug("[id={}] returned StatusChangeNotification ({}) sequenceNumber={}.", subscriptionId, status, sequenceNumber);
}
use of org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage in project milo by eclipse.
the class SubscriptionManager method republish.
public void republish(ServiceRequest service) {
RepublishRequest request = (RepublishRequest) service.getRequest();
if (subscriptions.isEmpty()) {
service.setServiceFault(StatusCodes.Bad_SubscriptionIdInvalid);
return;
}
UInteger subscriptionId = request.getSubscriptionId();
Subscription subscription = subscriptions.get(subscriptionId);
if (subscription == null) {
service.setServiceFault(StatusCodes.Bad_SubscriptionIdInvalid);
return;
}
UInteger sequenceNumber = request.getRetransmitSequenceNumber();
NotificationMessage notificationMessage = subscription.republish(sequenceNumber);
if (notificationMessage == null) {
service.setServiceFault(StatusCodes.Bad_MessageNotAvailable);
return;
}
ResponseHeader header = service.createResponseHeader();
RepublishResponse response = new RepublishResponse(header, notificationMessage);
service.setResponse(response);
}
use of org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage in project milo by eclipse.
the class OpcUaSubscriptionManager method onRepublishComplete.
private void onRepublishComplete(UInteger subscriptionId, RepublishResponse response, UInteger expectedSequenceNumber) throws UaException {
NotificationMessage notificationMessage = response.getNotificationMessage();
UInteger sequenceNumber = notificationMessage.getSequenceNumber();
if (!sequenceNumber.equals(expectedSequenceNumber)) {
throw new UaException(StatusCodes.Bad_SequenceNumberInvalid, "expected sequence=" + expectedSequenceNumber + ", received sequence=" + sequenceNumber);
}
DateTime publishTime = notificationMessage.getPublishTime();
logger.debug("onRepublishComplete(), subscriptionId={}, sequenceNumber={}, publishTime={}", subscriptionId, notificationMessage.getSequenceNumber(), publishTime);
OpcUaSubscription subscription = subscriptions.get(subscriptionId);
if (subscription != null) {
deliverNotificationMessage(subscription, notificationMessage);
}
}
Aggregations