homebridge-lgwebos-tv 4.2.2-beta.2 → 4.2.2-beta.4
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/package.json +1 -1
- package/src/lgwebossocket.js +12 -11
package/package.json
CHANGED
package/src/lgwebossocket.js
CHANGED
|
@@ -322,7 +322,7 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
322
322
|
this.cleanupSocket();
|
|
323
323
|
this.updateTvState();
|
|
324
324
|
})
|
|
325
|
-
.on('open',
|
|
325
|
+
.on('open', () => {
|
|
326
326
|
if (this.logDebug) this.emit('debug', `Plugin received heartbeat from TV`);
|
|
327
327
|
|
|
328
328
|
// connect to device success
|
|
@@ -331,18 +331,19 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
331
331
|
this.socketConnected = true;
|
|
332
332
|
|
|
333
333
|
// start heartbeat
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if (this.logDebug) this.emit('debug', `Socket send heartbeat`);
|
|
337
|
-
socket.ping();
|
|
338
|
-
}
|
|
339
|
-
}, 5000);
|
|
334
|
+
socket.ping();
|
|
335
|
+
if (this.logDebug) this.emit('debug', `Socket send heartbeat`);
|
|
340
336
|
})
|
|
341
337
|
.on('pong', async () => {
|
|
342
338
|
if (this.logDebug) this.emit('debug', `Socket received heartbeat`);
|
|
343
339
|
|
|
344
340
|
// Register to TV
|
|
345
341
|
if (!this.isRegistered) await this.registerToTv();
|
|
342
|
+
|
|
343
|
+
this.heartbeat = setTimeout(() => {
|
|
344
|
+
if (this.logDebug) this.emit('debug', `Socket send heartbeat`);
|
|
345
|
+
this.socket.ping();
|
|
346
|
+
}, 5000);
|
|
346
347
|
})
|
|
347
348
|
.on('message', async (message) => {
|
|
348
349
|
const parsedMessage = JSON.parse(message);
|
|
@@ -369,10 +370,6 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
369
370
|
this.emit('success', 'Pairing key saved');
|
|
370
371
|
}
|
|
371
372
|
|
|
372
|
-
//Request specjalized socket
|
|
373
|
-
this.specializedSocketId = await this.getCid();
|
|
374
|
-
await this.send('request', ApiUrls.SocketUrl, undefined, this.specializedSocketId);
|
|
375
|
-
|
|
376
373
|
//Request system info data
|
|
377
374
|
this.systemInfoId = await this.getCid();
|
|
378
375
|
await this.send('request', ApiUrls.GetSystemInfo, undefined, this.systemInfoId);
|
|
@@ -383,6 +380,10 @@ class LgWebOsSocket extends EventEmitter {
|
|
|
383
380
|
|
|
384
381
|
//Subscribe tv status
|
|
385
382
|
await this.subscribeTvStatus();
|
|
383
|
+
|
|
384
|
+
//Request specjalized socket
|
|
385
|
+
this.specializedSocketId = await this.getCid();
|
|
386
|
+
await this.send('request', ApiUrls.SocketUrl, undefined, this.specializedSocketId);
|
|
386
387
|
break;
|
|
387
388
|
case 'error':
|
|
388
389
|
if (this.logError) this.emit('error', `Register to TV error: ${stringifyMessage}, trying again`);
|