node-red-contrib-yandex-station-management 0.3.4 → 0.3.7

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.
@@ -291,12 +291,14 @@ module.exports = function(RED) {
291
291
  device.waitForListening = false;
292
292
  device.playAfterTTS = false;
293
293
  device.waitForIdle = false;
294
- device.watchDog = setTimeout(() => device.ws.close(), 10000);
294
+ device.watchDog = setTimeout(() => {
295
+ if (typeof(device) != 'undefined' && typeof(device.ws) != 'undefined') {device.ws.close()}
296
+ }, 10000);
295
297
  device.pingInterval = setInterval(onPing,300,device);
296
298
  debugMessage(`${device.id}: Kill connection watchdog`);
297
299
  clearTimeout(device.watchDogConn);
298
300
  clearTimeout(device.timer);
299
- debugMessage(`readyState: ${device.ws.readyState}`)
301
+ //debugMessage(`readyState: ${device.ws.readyState}`)
300
302
  });
301
303
  device.ws.on('message', function incoming(data) {
302
304
  //debugMessage(`${device.id}: ${JSON.stringify(data)}`);
@@ -369,11 +371,9 @@ module.exports = function(RED) {
369
371
  device.ws.on('error', function error(data){
370
372
  //statusUpdate({"color": "red", "text": "disconnected"}, device);
371
373
  debugMessage(`error: ${data}`);
372
- device.ws.terminate();
373
- // if (device.localConnectionFlag) {
374
- // debugMessage(`Reconnecting in 60 seconds...` );
375
- // setTimeout(connect, 60000, device);
376
- // }
374
+ if (typeof(device) !== 'undefined' && typeof(device.ws) !== 'undefined' ) {
375
+ device.ws.terminate();
376
+ }
377
377
  });
378
378
  };
379
379
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-yandex-station-management",
3
- "version": "0.3.4",
3
+ "version": "0.3.7",
4
4
  "description": "Local management of YandexStation using API on websockets",
5
5
  "main": "index.js",
6
6
  "scripts": {