node-opcua-utils
Advanced tools
Comparing version 2.0.0-alpha.12 to 2.0.0-alpha.13
@@ -33,4 +33,4 @@ /** | ||
export { getFunctionParameterNames } from "./get_function_parameters_name"; | ||
export { WatchDog } from "./watchdog"; | ||
export * from "./watchdog"; | ||
export { LineFile } from "./linefile"; | ||
export { setDeprecated } from "./set_deprecated"; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -74,4 +77,3 @@ /** | ||
exports.getFunctionParameterNames = get_function_parameters_name_1.getFunctionParameterNames; | ||
var watchdog_1 = require("./watchdog"); | ||
exports.WatchDog = watchdog_1.WatchDog; | ||
__export(require("./watchdog")); | ||
var linefile_1 = require("./linefile"); | ||
@@ -78,0 +80,0 @@ exports.LineFile = linefile_1.LineFile; |
@@ -15,3 +15,3 @@ /// <reference types="node" /> | ||
_watchDog?: WatchDog; | ||
_watchDogData: IWatchdogData2; | ||
_watchDogData?: IWatchdogData2; | ||
watchdogReset: () => void; | ||
@@ -24,4 +24,2 @@ keepAlive?: () => void; | ||
* returns the number of subscribers using the WatchDog object. | ||
* @property subscriberCount | ||
* @type {number} | ||
*/ | ||
@@ -47,3 +45,3 @@ readonly subscriberCount: number; | ||
* @param timeout | ||
* @return {number} | ||
* @return the numerical key associated with this subscriber | ||
*/ | ||
@@ -50,0 +48,0 @@ addSubscriber(subscriber: ISubscriber, timeout: number): number; |
@@ -16,2 +16,5 @@ "use strict"; | ||
node_opcua_assert_1.assert(self._watchDog instanceof WatchDog); | ||
if (!self._watchDogData) { | ||
throw new Error("Internal error"); | ||
} | ||
node_opcua_assert_1.assert(_.isNumber(self._watchDogData.key)); | ||
@@ -26,4 +29,2 @@ self._watchDogData.lastSeen = Date.now(); | ||
* returns the number of subscribers using the WatchDog object. | ||
* @property subscriberCount | ||
* @type {number} | ||
*/ | ||
@@ -53,3 +54,3 @@ get subscriberCount() { | ||
* @param timeout | ||
* @return {number} | ||
* @return the numerical key associated with this subscriber | ||
*/ | ||
@@ -89,2 +90,5 @@ addSubscriber(subscriber, timeout) { | ||
} | ||
if (!subscriber._watchDogData) { | ||
throw new Error("Internal error"); | ||
} | ||
node_opcua_assert_1.assert(subscriber._watchDog instanceof WatchDog); | ||
@@ -99,3 +103,2 @@ node_opcua_assert_1.assert(_.isNumber(subscriber._watchDogData.key)); | ||
// delete timer when the last subscriber comes out | ||
// xx console.log("xxxx WatchDog.prototype.removeSubscriber ",this.subscriberCount ); | ||
if (this.subscriberCount === 0) { | ||
@@ -102,0 +105,0 @@ this._stop_timer(); |
{ | ||
"name": "node-opcua-utils", | ||
"version": "2.0.0-alpha.12", | ||
"version": "2.0.0-alpha.13", | ||
"description": "pure nodejs OPCUA SDK - module -utils", | ||
@@ -38,3 +38,3 @@ "main": "./dist/index.js", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "61699a99c75c631388f2e8d8e33eb209649c5eac" | ||
"gitHead": "6a0c56afb819a44d5abd453d39ce684df6fb3505" | ||
} |
@@ -64,4 +64,4 @@ /** | ||
export { getFunctionParameterNames } from "./get_function_parameters_name"; | ||
export { WatchDog } from "./watchdog"; | ||
export * from "./watchdog"; | ||
export { LineFile } from "./linefile"; | ||
export { setDeprecated } from "./set_deprecated"; |
@@ -15,5 +15,8 @@ /** | ||
} | ||
export interface ISubscriber { | ||
_watchDog?: WatchDog; | ||
_watchDogData: IWatchdogData2; | ||
_watchDogData?: IWatchdogData2; | ||
watchdogReset: () => void; | ||
@@ -32,2 +35,6 @@ keepAlive?: () => void; | ||
assert(self._watchDog instanceof WatchDog); | ||
if (!self._watchDogData) { | ||
throw new Error("Internal error"); | ||
} | ||
assert(_.isNumber(self._watchDogData.key)); | ||
@@ -43,4 +50,2 @@ self._watchDogData.lastSeen = Date.now(); | ||
* returns the number of subscribers using the WatchDog object. | ||
* @property subscriberCount | ||
* @type {number} | ||
*/ | ||
@@ -50,2 +55,3 @@ get subscriberCount(): number { | ||
} | ||
private readonly _watchdogDataMap: { [id: number]: IWatchdogData2 }; | ||
@@ -79,5 +85,5 @@ private _counter: number; | ||
* @param timeout | ||
* @return {number} | ||
* @return the numerical key associated with this subscriber | ||
*/ | ||
public addSubscriber(subscriber: ISubscriber, timeout: number) { | ||
public addSubscriber(subscriber: ISubscriber, timeout: number): number { | ||
const self = this; | ||
@@ -122,2 +128,6 @@ self._currentTime = Date.now(); | ||
} | ||
if (!subscriber._watchDogData) { | ||
throw new Error("Internal error"); | ||
} | ||
assert(subscriber._watchDog instanceof WatchDog); | ||
@@ -134,3 +144,2 @@ assert(_.isNumber(subscriber._watchDogData.key)); | ||
// delete timer when the last subscriber comes out | ||
// xx console.log("xxxx WatchDog.prototype.removeSubscriber ",this.subscriberCount ); | ||
if (this.subscriberCount === 0) { | ||
@@ -143,4 +152,4 @@ this._stop_timer(); | ||
assert( | ||
this._timer === null && Object.keys(this._watchdogDataMap).length === 0, | ||
" leaking subscriber in watchdog" | ||
this._timer === null && Object.keys(this._watchdogDataMap).length === 0, | ||
" leaking subscriber in watchdog" | ||
); | ||
@@ -174,2 +183,3 @@ } | ||
} | ||
private _stop_timer(): void { | ||
@@ -176,0 +186,0 @@ assert(this._timer !== null, "_stop_timer already called ?"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49369
956