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

add error event

上级 5007f17e
...@@ -61,7 +61,7 @@ Then you are set. ...@@ -61,7 +61,7 @@ Then you are set.
> Cloud9 IDE written in JavaScript, uses Node.js on the back-end. It uses Docker containers for its workspaces, and hosted on Google Compute Engine. > Cloud9 IDE written in JavaScript, uses Node.js on the back-end. It uses Docker containers for its workspaces, and hosted on Google Compute Engine.
### 1. Open Cloud9 IDE ### 1. Open in Cloud9 IDE
Just one click here: <a href="https://c9.io/open/?name=Wechaty&type=nodejs&clone_url=https://github.com/zixia/wechaty.git&description=Wechat%20for%20Bot&selection_file=/example/ding-dong-bot.js" target="_blank"><img src="https://img.shields.io/badge/open%20in-Cloud9%20IDE-blue.svg" alt="Open Wechaty in Cloud9 IDE"></a> Just one click here: <a href="https://c9.io/open/?name=Wechaty&type=nodejs&clone_url=https://github.com/zixia/wechaty.git&description=Wechat%20for%20Bot&selection_file=/example/ding-dong-bot.js" target="_blank"><img src="https://img.shields.io/badge/open%20in-Cloud9%20IDE-blue.svg" alt="Open Wechaty in Cloud9 IDE"></a>
......
...@@ -45,8 +45,8 @@ return (function(port) { ...@@ -45,8 +45,8 @@ return (function(port) {
// variable // variable
, vars: { , vars: {
logined: false loginStatus: false
, inited: false , initStatus: false
, socket: null , socket: null
, eventsBuf: [] , eventsBuf: []
...@@ -103,7 +103,7 @@ return (function(port) { ...@@ -103,7 +103,7 @@ return (function(port) {
return retObj return retObj
} }
if (Wechaty.vars.inited === true) { if (Wechaty.vars.initStatus === true) {
log('Wechaty.init() called twice: already inited') log('Wechaty.init() called twice: already inited')
retObj.code = 304 // 304 Not Modified https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5 retObj.code = 304 // 304 Not Modified https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
retObj.message = 'init() already inited before. returned with do nothing' retObj.message = 'init() already inited before. returned with do nothing'
...@@ -131,7 +131,7 @@ return (function(port) { ...@@ -131,7 +131,7 @@ return (function(port) {
heartBeat(true) heartBeat(true)
clog('inited!. ;-D') clog('inited!. ;-D')
Wechaty.vars.inited = true Wechaty.vars.initStatus = true
retObj.code = 200 retObj.code = 200
retObj.message = 'Wechaty Init Succ on port: ' + port retObj.message = 'Wechaty Init Succ on port: ' + port
...@@ -354,17 +354,17 @@ return (function(port) { ...@@ -354,17 +354,17 @@ return (function(port) {
return return
} }
function isLogin() { return !!Wechaty.vars.logined } function isLogin() { return !!Wechaty.vars.loginStatus }
function login(data) { function login(data) {
log('login(' + data + ')') log('login(' + data + ')')
if (!Wechaty.vars.logined) { if (!Wechaty.vars.loginStatus) {
Wechaty.vars.logined = true Wechaty.vars.loginStatus = true
Wechaty.emit('login', data) Wechaty.emit('login', data)
} }
} }
function logout(data) { function logout(data) {
log('logout(' + data + ')') log('logout(' + data + ')')
Wechaty.vars.logined = false Wechaty.vars.loginStatus = false
Wechaty.emit('logout', data) Wechaty.emit('logout', data)
checkScan() checkScan()
} }
......
...@@ -95,10 +95,12 @@ class Wechaty extends EventEmitter { ...@@ -95,10 +95,12 @@ class Wechaty extends EventEmitter {
this.puppet.on('logout', (e) => { this.puppet.on('logout', (e) => {
this.emit('logout', e) this.emit('logout', e)
}) })
this.puppet.on('error', (e) => {
this.emit('error', e)
})
/** /**
* TODO: support more events: * TODO: support more events:
* 1. error
* 2. send * 2. send
* 3. reply * 3. reply
* 4. quit * 4. quit
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册