Search in sources :

Example 6 with NotificationMessage

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);
}
Also used : PublishResponse(org.eclipse.milo.opcua.stack.core.types.structured.PublishResponse) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) NotificationMessage(org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) StatusChangeNotification(org.eclipse.milo.opcua.stack.core.types.structured.StatusChangeNotification)

Example 7 with NotificationMessage

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);
}
Also used : ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) NotificationMessage(org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) RepublishResponse(org.eclipse.milo.opcua.stack.core.types.structured.RepublishResponse) RepublishRequest(org.eclipse.milo.opcua.stack.core.types.structured.RepublishRequest)

Example 8 with NotificationMessage

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);
    }
}
Also used : NotificationMessage(org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage) UaException(org.eclipse.milo.opcua.stack.core.UaException) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) DateTime(org.eclipse.milo.opcua.stack.core.types.builtin.DateTime)

Aggregations

NotificationMessage (org.eclipse.milo.opcua.stack.core.types.structured.NotificationMessage)8 UInteger (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger)7 PublishResponse (org.eclipse.milo.opcua.stack.core.types.structured.PublishResponse)5 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)4 Map (java.util.Map)3 UaException (org.eclipse.milo.opcua.stack.core.UaException)3 DateTime (org.eclipse.milo.opcua.stack.core.types.builtin.DateTime)3 ExtensionObject (org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject)3 ResponseHeader (org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader)3 ImmutableList (com.google.common.collect.ImmutableList)2 Lists (com.google.common.collect.Lists)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 Maps (com.google.common.collect.Maps)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 List (java.util.List)2 CompletableFuture (java.util.concurrent.CompletableFuture)2