jsgar 1.4.4 → 1.5.2
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 +25 -10
- package/package.json +1 -1
package/dist/gar.umd.js
CHANGED
|
@@ -52,8 +52,18 @@
|
|
|
52
52
|
this.heartbeatInterval = heartbeatInterval;
|
|
53
53
|
this.version = 650269;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (typeof window !== 'undefined' && window.location) {
|
|
56
|
+
this.application = window.location.href;
|
|
57
|
+
} else if (typeof require !== 'undefined' && require.main) {
|
|
58
|
+
this.application = require.main.filename;
|
|
59
|
+
} else {
|
|
60
|
+
this.application = 'unknown-js';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.serverTopicIdToName = new Map();
|
|
64
|
+
this.serverTopicNameToId = new Map();
|
|
65
|
+
this.serverKeyIdToName = new Map();
|
|
66
|
+
this.serverKeyNameToId = new Map();
|
|
57
67
|
this.localTopicCounter = 1;
|
|
58
68
|
this.localKeyCounter = 1;
|
|
59
69
|
this.localTopicMap = new Map();
|
|
@@ -395,12 +405,12 @@
|
|
|
395
405
|
this.registerKeyIntroductionHandler((keyId, name, _class) =>
|
|
396
406
|
this.log('DEBUG', `New server key: ${name} (Server ID: ${keyId})`));
|
|
397
407
|
this.registerDeleteKeyHandler((keyId) =>
|
|
398
|
-
this.log('DEBUG', `Delete key: ${this.
|
|
408
|
+
this.log('DEBUG', `Delete key: ${this.serverKeyIdToName.get(keyId) || 'unknown'} (Server ID: ${keyId})`));
|
|
399
409
|
this.registerSubscriptionStatusHandler(this._defaultSubscriptionStatusHandler.bind(this));
|
|
400
410
|
this.registerDeleteRecordHandler((keyId, topicId) =>
|
|
401
|
-
this.log('DEBUG', `Delete record: ${this.
|
|
411
|
+
this.log('DEBUG', `Delete record: ${this.serverKeyIdToName.get(keyId) || 'unknown'} - ${this.serverTopicIdToName.get(topicId) || 'unknown'}`));
|
|
402
412
|
this.registerRecordUpdateHandler((keyId, topicId, value) =>
|
|
403
|
-
this.log('DEBUG', `Record update: ${this.
|
|
413
|
+
this.log('DEBUG', `Record update: ${this.serverKeyIdToName.get(keyId) || 'unknown'} - ${this.serverTopicIdToName.get(topicId) || 'unknown'} = ${JSON.stringify(value)}`));
|
|
404
414
|
this.registerShutdownHandler(() => this.log('INFO', 'Shutdown received'));
|
|
405
415
|
}
|
|
406
416
|
|
|
@@ -547,11 +557,14 @@
|
|
|
547
557
|
_processMessage(message) {
|
|
548
558
|
const msgType = message.message_type;
|
|
549
559
|
if (msgType === 'TopicIntroduction') {
|
|
550
|
-
this.
|
|
560
|
+
this.serverTopicIdToName.set(message.value.topic_id, message.value.name);
|
|
561
|
+
this.serverTopicNameToId.set(message.value.name, message.value.topic_id);
|
|
551
562
|
} else if (msgType === 'KeyIntroduction') {
|
|
552
|
-
this.
|
|
563
|
+
this.serverKeyIdToName.set(message.value.key_id, message.value.name);
|
|
564
|
+
this.serverKeyNameToId.set(message.value.name, message.value.key_id);
|
|
553
565
|
} else if (msgType === 'DeleteKey') {
|
|
554
|
-
this.
|
|
566
|
+
this.serverKeyNameToId.delete(this.serverKeyIdToName.get(message.value.key_id) || "");
|
|
567
|
+
this.serverKeyIdToName.delete(message.value.key_id);
|
|
555
568
|
} else if (msgType === 'Heartbeat') {
|
|
556
569
|
this.lastHeartbeatTime = Date.now() / 1000;
|
|
557
570
|
if (this._initialGracePeriod) {
|
|
@@ -559,8 +572,10 @@
|
|
|
559
572
|
}
|
|
560
573
|
} else if (msgType === 'Introduction') {
|
|
561
574
|
const value = message.value;
|
|
562
|
-
this.
|
|
563
|
-
this.
|
|
575
|
+
this.serverTopicIdToName.clear();
|
|
576
|
+
this.serverTopicNameToId.clear();
|
|
577
|
+
this.serverKeyIdToName.clear();
|
|
578
|
+
this.serverKeyNameToId.clear();
|
|
564
579
|
this.recordMap.clear();
|
|
565
580
|
this.heartbeatTimeout = Math.max(this.heartbeatTimeout, value.heartbeat_timeout_interval / 1000);
|
|
566
581
|
this.lastHeartbeatTime = Date.now() / 1000;
|