node-opcua-server 2.73.0 → 2.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,9 +6,7 @@
6
6
  import { EventEmitter } from "events";
7
7
  import * as chalk from "chalk";
8
8
 
9
- import { AddressSpace, BaseNode, Duration, UAObjectType } from "node-opcua-address-space";
10
- import { checkSelectClauses } from "node-opcua-address-space";
11
- import { SessionContext } from "node-opcua-address-space";
9
+ import { SessionContext,AddressSpace, BaseNode, Duration, UAObjectType } from "node-opcua-address-space";
12
10
  import { assert } from "node-opcua-assert";
13
11
  import { Byte, UInt32 } from "node-opcua-basic-types";
14
12
  import { SubscriptionDiagnosticsDataType } from "node-opcua-common";
@@ -18,7 +16,7 @@ import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug
18
16
  import { NodeId } from "node-opcua-nodeid";
19
17
  import { ObjectRegistry } from "node-opcua-object-registry";
20
18
  import { SequenceNumberGenerator } from "node-opcua-secure-channel";
21
- import { EventFilter } from "node-opcua-service-filter";
19
+ import { EventFilter, checkSelectClauses } from "node-opcua-service-filter";
22
20
  import { AggregateFilter } from "node-opcua-service-subscription";
23
21
  import {
24
22
  DataChangeNotification,
@@ -629,7 +627,7 @@ export class Subscription extends EventEmitter {
629
627
  this.messageSent = false;
630
628
 
631
629
  this.timerId = null;
632
- this._start_timer();
630
+ this._start_timer({ firstTime: true });
633
631
 
634
632
  debugLog(chalk.green(`creating subscription ${this.id}`));
635
633
 
@@ -686,7 +684,7 @@ export class Subscription extends EventEmitter {
686
684
  // todo
687
685
  }
688
686
  this._stop_timer();
689
- this._start_timer();
687
+ this._start_timer({ firstTime: false });
690
688
  }
691
689
 
692
690
  /**
@@ -732,7 +730,7 @@ export class Subscription extends EventEmitter {
732
730
  public increaseLifeTimeCounter(): void {
733
731
  this._life_time_counter += 1;
734
732
  if (this._life_time_counter >= this.lifeTimeCount) {
735
- this.emit("lifeTimeExpired");
733
+ this.emit("lifeTimeExpired");
736
734
  }
737
735
  this.emit("lifeTimeCounterChanged", this._life_time_counter);
738
736
  }
@@ -1458,7 +1456,7 @@ export class Subscription extends EventEmitter {
1458
1456
  }
1459
1457
  }
1460
1458
 
1461
- private _start_timer() {
1459
+ private _start_timer({ firstTime }: { firstTime: boolean }) {
1462
1460
  debugLog(
1463
1461
  chalk.bgWhite.blue("Subscription#_start_timer subscriptionId="),
1464
1462
  this.id,
@@ -1478,8 +1476,11 @@ export class Subscription extends EventEmitter {
1478
1476
  // make sure that a keep-alive Message will be send at the end of the first publishing cycle
1479
1477
  // if there are no Notifications ready.
1480
1478
  this._keep_alive_counter = 0; // this.maxKeepAliveCount;
1481
- assert(this.messageSent === false);
1482
- assert(this.state === SubscriptionState.CREATING);
1479
+
1480
+ if (firstTime) {
1481
+ assert(this.messageSent === false);
1482
+ assert(this.state === SubscriptionState.CREATING);
1483
+ }
1483
1484
 
1484
1485
  assert(this.publishingInterval >= Subscription.minimumPublishingInterval);
1485
1486
  this.timerId = setInterval(this._tick.bind(this), this.publishingInterval);