How to use the node-opcua-service-subscription.NotificationMessage 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_subscription.ts View on Github external
assert(notificationData.length === 1 || notificationData.length === 2); // as per spec part 3.

    // istanbul ignore next
    if (doDebug) {
      debugLog(chalk.yellow("Subscription#_addNotificationMessage"),
        notificationData.toString());
    }
    const subscription = this;
    assert(_.isObject(notificationData[0]));

    assert_validNotificationData(notificationData[0]);
    if (notificationData.length === 2) {
      assert_validNotificationData(notificationData[1]);
    }

    const notification_message = new NotificationMessage({
      notificationData,
      publishTime: new Date(),
      sequenceNumber: this._get_next_sequence_number()
    });

    subscription._pending_notifications.push({
      notification: notification_message,
      publishTime: new Date(),
      sequenceNumber: notification_message.sequenceNumber,
      start_tick: subscription.publishIntervalCount
    });
    debugLog("pending notification to send ", subscription._pending_notifications.length);

  }