diff --git a/package.json b/package.json index 951f46d2b3aca276a7060717229580878740f573..913f9b0723bb318f615873fbe28f7705a4fb9cc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty" - , "version": "0.2.5" + , "version": "0.2.6" , "description": "Wechat for Bot. (Personal Account NOT Official Account)" , "main": "index.js" , "scripts": { diff --git a/src/puppet-web/watchdog.js b/src/puppet-web/watchdog.js index 91220e39ec9083be6dd88e60998d3ffcae5af801..32ead3437469b277d24e020e1552db60329ecb7f 100644 --- a/src/puppet-web/watchdog.js +++ b/src/puppet-web/watchdog.js @@ -28,20 +28,14 @@ const Watchdog = { // feed me in time(after 1st feed), or I'll restart system function onFeed({ data - , type = 'GARBAGE' + , type = 'HEARTBEAT' , timeout = 60000 // 60s default. can be override in options but be careful about the number zero(0) } = {}) { if (!this) { - throw new Error('onFeed() must has `this`') + throw new Error('onFeed() must has `this` of instanceof PuppetWeb') } - // console.log('#################') - // console.log(typeof this) - // console.log(this.constructor.name) - // console.log(this) - // throw new Error('faint') - process.nextTick(_ => { log.verbose('PuppetWebWatchdog', 'onFeed: %s, %d, [%s]', type, timeout, data) @@ -50,8 +44,8 @@ function onFeed({ clearWatchDogTimer.call(this) return - case 'GARBAGE': case 'SCAN': + case 'HEARTBEAT': break default: @@ -64,7 +58,7 @@ function onFeed({ monitorScan.call(this, type) autoSaveSession.call(this) - }) + }) // end nextTick } diff --git a/src/wechaty-io.js b/src/wechaty-io.js index 7cf707e7ce84b4a1bdb44313962540a6bd4b2256..935b92ad4893c5bf194adabcf829b9ea81f7be8d 100644 --- a/src/wechaty-io.js +++ b/src/wechaty-io.js @@ -72,7 +72,7 @@ class WechatyIo { ws.send('Wechaty version ' + this.wechaty.version()) }.bind(this)) - ws.on('message', function(data, flags) { + ws.on('message', (data, flags) => { log.verbose('WechatyIo', 'WebSocket got message') // flags.binary will be set if a binary data is received. // flags.masked will be set if the data was masked. @@ -87,7 +87,7 @@ class WechatyIo { log.warn('WechatyIo', 'onMessage server push function invalid') } } - }.bind(this)) + }) ws .on('close', e => {