提交 d14d7104 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

code clean

上级 ff4293f8
{
"name": "wechaty"
, "version": "0.2.5"
, "version": "0.2.6"
, "description": "Wechat for Bot. (Personal Account NOT Official Account)"
, "main": "index.js"
, "scripts": {
......
......@@ -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
}
......
......@@ -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 => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册