How to use the node-opcua-service-subscription.TransferResult function in node-opcua-service-subscription

To help you get started, we’ve selected a few node-opcua-service-subscription examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server / source / server_engine.ts View on Github external
public transferSubscription(
    session: ServerSession,
    subscriptionId: number,
    sendInitialValues: boolean): TransferResult {

    assert(session instanceof ServerSession);
    assert(_.isNumber(subscriptionId));
    assert(_.isBoolean(sendInitialValues));

    if (subscriptionId <= 0) {
      return new TransferResult({ statusCode: StatusCodes.BadSubscriptionIdInvalid });
    }

    const subscription = this.findSubscription(subscriptionId);
    if (!subscription) {
      return new TransferResult({ statusCode: StatusCodes.BadSubscriptionIdInvalid });
    }
    if (!subscription.$session) {
      return new TransferResult({ statusCode: StatusCodes.BadInternalError });
    }

    // update diagnostics 
    subscription.subscriptionDiagnostics.transferRequestCount++;

    // now check that new session has sufficient right
    // if (session.authenticationToken.toString() !== subscription.authenticationToken.toString()) {
    //     console.log("ServerEngine#transferSubscription => BadUserAccessDenied");
github node-opcua / node-opcua / packages / node-opcua-server / source / server_engine.ts View on Github external
subscription.$session._unexposeSubscriptionDiagnostics(subscription);
    ServerSidePublishEngine.transferSubscription(subscription, session.publishEngine, sendInitialValues);

    subscription.$session = session;

    session._exposeSubscriptionDiagnostics(subscription);

    assert(subscription.publishEngine === session.publishEngine);
    assert(session.publishEngine.subscriptionCount === nbSubscriptionBefore + 1);

    // TODO: If the Server transfers the Subscription to the new Session, the Server shall issue a
    //       StatusChangeNotification notificationMessage with the status code Good_SubscriptionTransferred
    //       to the old Session.

    const result = new TransferResult({
      availableSequenceNumbers: subscription.getAvailableSequenceNumbers(),
      statusCode: StatusCodes.Good
    });

    // istanbul ignore next
    if (doDebug) {
      debugLog("TransferResult", result.toString());
    }

    return result;

  }
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
const nbSubscriptionBefore = session.publishEngine.subscriptionCount;

    subscription.$session._unexposeSubscriptionDiagnostics(subscription);
    ServerSidePublishEngine.transferSubscription(subscription, session.publishEngine, sendInitialValues);
    subscription.$session = session;

    session._exposeSubscriptionDiagnostics(subscription);

    assert(subscription.publishEngine === session.publishEngine);
    assert(session.publishEngine.subscriptionCount === nbSubscriptionBefore + 1);

    // TODO: If the Server transfers the Subscription to the new Session, the Server shall issue a
    //       StatusChangeNotification notificationMessage with the status code Good_SubscriptionTransferred
    //       to the old Session.

    const result = new TransferResult({
        statusCode: StatusCodes.Good,
        availableSequenceNumbers: subscription.getAvailableSequenceNumbers()
    });

    // istanbul ignore next
    if (doDebug) {
        debugLog("TransferResult", result.toString());
    }

    return result;

};