diff --git a/dist/monkey.js b/dist/monkey.js index 804ef65..27ad341 100644 --- a/dist/monkey.js +++ b/dist/monkey.js @@ -400,8 +400,12 @@ return /******/ (function(modules) { // webpackBootstrap this._sendCommand(this.enums.ProtocolCommand.MESSAGE, args); watchdog.messageInTransit(function () { - this.socketConnection.onclose = function () {}; - this.socketConnection.close(); + if (this.socketConnection != null) { + this.socketConnection.onclose = function () {}; + this.socketConnection.close(); + this.socketConnection = null; + } + setTimeout(function () { this.startConnection(); }.bind(this), 5000); @@ -950,8 +954,12 @@ return /******/ (function(modules) { // webpackBootstrap //set watchdog if (arrayMessages.length > 0) { watchdog.messageInTransit(function () { - this.socketConnection.onclose = function () {}; - this.socketConnection.close(); + if (this.socketConnection != null) { + this.socketConnection.onclose = function () {}; + this.socketConnection.close(); + this.socketConnection = null; + } + setTimeout(function () { this.startConnection(); }.bind(this), 5000); diff --git a/main.js b/main.js index 408e1fd..8f9257f 100644 --- a/main.js +++ b/main.js @@ -340,8 +340,12 @@ require('es6-promise').polyfill(); this._sendCommand(this.enums.ProtocolCommand.MESSAGE, args); watchdog.messageInTransit(function(){ - this.socketConnection.onclose = function(){}; - this.socketConnection.close(); + if (this.socketConnection != null){ + this.socketConnection.onclose = function(){}; + this.socketConnection.close(); + this.socketConnection = null; + } + setTimeout(function(){ this.startConnection() }.bind(this), 5000); @@ -884,8 +888,12 @@ require('es6-promise').polyfill(); //set watchdog if (arrayMessages.length > 0) { watchdog.messageInTransit(function(){ - this.socketConnection.onclose = function(){}; - this.socketConnection.close(); + if (this.socketConnection != null) { + this.socketConnection.onclose = function(){}; + this.socketConnection.close(); + this.socketConnection = null; + } + setTimeout(function(){ this.startConnection(); }.bind(this), 5000); diff --git a/package.json b/package.json index f1a5126..35c3f51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monkey-sdk", - "version": "0.8.4", + "version": "0.8.5", "description": "Monkey SDK for web", "main": "./dist/monkey.js", "scripts": {