jsgar 1.1.0 → 1.2.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.
- package/dist/gar.umd.js +6 -3
- package/package.json +1 -1
package/dist/gar.umd.js
CHANGED
|
@@ -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
|
}
|