Skip to content

Commit

Permalink
fix(core): heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 1, 2020
1 parent 6ec47b3 commit 36a4602
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/koishi-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ export class App extends Context {
}

emitEvent <K extends Events> (meta: Meta, event: K, ...payload: Parameters<EventMap[K]>) {
if (!meta.$ctxType) {
this.logger('receiver').debug('/', 'emits', event)
this.receiver.emit(event, ...payload)
return
}

for (const path in this._contexts) {
const context = this._contexts[path]
if (!context.match(meta)) continue
Expand Down
3 changes: 3 additions & 0 deletions packages/koishi-core/tests/receiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,8 @@ describe('Receiver API', () => {
expect(app.server.parseMeta(meta)).toMatchObject(['heartbeat'])
expect(meta.$ctxType).toBeFalsy()
expect(meta.$ctxId).toBeFalsy()

// make coverage happy
expect(app.server.dispatchMeta(meta))
})
})

0 comments on commit 36a4602

Please sign in to comment.