Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
feat: add meta events: lifecycle and heartbeat.
Browse files Browse the repository at this point in the history
  • Loading branch information
MomoCow committed Oct 22, 2018
1 parent 46ad8cb commit bd8b9f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/event-bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class CQEventBus {
pre: [],
post: []
}
},
meta_event: {
'': [],
lifecycle: [],
heartbeat: []
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ class CQWebsocket extends $Callable {
this._eventBus.emit('error', new Error(`Unexpected "request_type"\n${JSON.stringify(msgObj, null, 2)}`))
}
break
case 'meta_event':
switch (msgObj.meta_event_type) {
case 'lifecycle':
this._eventBus.emit('meta_event.lifecycle', msgObj)
break
case 'heartbeat':
this._eventBus.emit('meta_event.heartbeat', msgObj)
break
default:
this._eventBus.emit('error', new Error(`Unexpected "meta_event_type"\n${JSON.stringify(msgObj, null, 2)}`))
}
break
default:
this._eventBus.emit('error', new Error(`Unexpected "post_type"\n${JSON.stringify(msgObj, null, 2)}`))
}
Expand Down

0 comments on commit bd8b9f9

Please sign in to comment.