jsgar 1.1.0 → 1.2.1
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.
- package/dist/gar.umd.js +9 -5
- package/package.json +1 -1
package/dist/gar.umd.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
//for browser:
|
|
29
29
|
const WebSocket = window.WebSocket;
|
|
30
30
|
|
|
31
|
-
// for Node.
|
|
31
|
+
// for Node.js:
|
|
32
32
|
// import ws from 'ws';
|
|
33
33
|
// const WebSocket = ws;
|
|
34
34
|
|
|
@@ -211,7 +211,10 @@
|
|
|
211
211
|
* @param {Function} handler - Callback with no arguments
|
|
212
212
|
*/
|
|
213
213
|
registerHeartbeatHandler(handler) {
|
|
214
|
-
this.registerHandler('Heartbeat', () =>
|
|
214
|
+
this.registerHandler('Heartbeat', (msg) => {
|
|
215
|
+
const value = msg.value;
|
|
216
|
+
handler(value.u_milliseconds);
|
|
217
|
+
});
|
|
215
218
|
}
|
|
216
219
|
|
|
217
220
|
clearHeartbeatHandler() {
|
|
@@ -367,7 +370,7 @@
|
|
|
367
370
|
registerDefaultHandlers() {
|
|
368
371
|
this.registerIntroductionHandler((version, interval, user, _schema) =>
|
|
369
372
|
this.log('INFO', `Connected to server: ${user}`));
|
|
370
|
-
this.registerHeartbeatHandler(() => this.log('DEBUG',
|
|
373
|
+
this.registerHeartbeatHandler((u_milliseconds) => this.log('DEBUG', `Heartbeat received ${u_milliseconds}}`));
|
|
371
374
|
this.registerLogoffHandler(() => this.log('INFO', 'Logoff received'));
|
|
372
375
|
this.registerTopicIntroductionHandler((topicId, name) =>
|
|
373
376
|
this.log('INFO', `New server topic: ${name} (Server ID: ${topicId})`));
|
|
@@ -473,7 +476,7 @@
|
|
|
473
476
|
*/
|
|
474
477
|
_heartbeatLoop() {
|
|
475
478
|
if (this.running) {
|
|
476
|
-
this.sendMessage({ message_type: 'Heartbeat' });
|
|
479
|
+
this.sendMessage({ message_type: 'Heartbeat', value: { u_milliseconds: Date.now() } });
|
|
477
480
|
this.checkHeartbeat();
|
|
478
481
|
}
|
|
479
482
|
}
|
|
@@ -555,13 +558,14 @@
|
|
|
555
558
|
* @param {string|null} [keyFilter=null] - Key filter regex
|
|
556
559
|
* @param {string|null} [topicFilter=null] - Topic filter regex
|
|
557
560
|
*/
|
|
558
|
-
subscribe(name, mode = 'Streaming', keyName = null, topicName = null, classFilter = null, keyFilter = null, topicFilter = null) {
|
|
561
|
+
subscribe(name, mode = 'Streaming', keyName = null, topicName = null, classFilter = null, keyFilter = null, topicFilter = null, include_unknown_keys = false) {
|
|
559
562
|
const keyId = keyName ? this.getAndPossiblyIntroduceKeyId(keyName) : 0;
|
|
560
563
|
const topicId = topicName ? this.getAndPossiblyIntroduceTopicId(topicName) : 0;
|
|
561
564
|
const subMsg = {
|
|
562
565
|
message_type: 'Subscribe',
|
|
563
566
|
value: {
|
|
564
567
|
subscription_mode: mode,
|
|
568
|
+
include_unknown_keys: include_unknown_keys,
|
|
565
569
|
nagle_interval: 0,
|
|
566
570
|
name,
|
|
567
571
|
key_id: keyId,
|