Skip to content

Commit

Permalink
fix(qq): resume
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme committed Jul 18, 2024
1 parent 1080073 commit d83f024
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions adapters/qq/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ export class WsClient<C extends Context = Context> extends Adapter.WsClient<C, Q
this._sessionId = ''
this._s = null
this.bot.logger.warn('offline: invalid session')
this.socket?.close()
} else if (parsed.op === Opcode.RECONNECT) {
this.bot.logger.warn('offline: server request reconnect')
this.socket?.close()
} else if (parsed.op === Opcode.DISPATCH) {
this.bot.dispatch(this.bot.session({
type: 'internal',
Expand All @@ -84,6 +82,10 @@ export class WsClient<C extends Context = Context> extends Adapter.WsClient<C, Q

this.socket.addEventListener('close', (e) => {
this.bot.logger.debug('websocket closed, code %o, reason: %s', e.code, e.reason)
if (e.code > 4000 && ![4008, 4009].includes(e.code)) {
this._sessionId = ''
this._s = null
}
clearInterval(this._ping)
})
}
Expand Down

0 comments on commit d83f024

Please sign in to comment.