MCPcopy
hub / github.com/wechaty/wechaty / stop

Method stop

src/io.ts:505–539  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

503 }
504
505 public async stop (): Promise<void> {
506 log.verbose('Io', 'stop()')
507
508 if (!this.ws) {
509 throw new Error('no ws')
510 }
511
512 this.state.off('pending')
513
514 // try to send IoEvents in buffer
515 await this.send()
516 this.eventBuffer = []
517
518 if (this.reconnectTimer) {
519 clearTimeout(this.reconnectTimer)
520 this.reconnectTimer = undefined
521 }
522
523 if (this.lifeTimer) {
524 clearInterval(this.lifeTimer)
525 this.lifeTimer = undefined
526 }
527
528 this.ws.close()
529 await new Promise<void>(resolve => {
530 if (this.ws) {
531 this.ws.once('close', resolve)
532 } else {
533 resolve()
534 }
535 })
536 this.ws = undefined
537
538 this.state.off(true)
539 }
540
541 /**
542 *

Callers 8

io.spec.tsFile · 0.45
wechaty.spec.tsFile · 0.45
plugin.spec.tsFile · 0.45
message.spec.tsFile · 0.45
contact.spec.tsFile · 0.45
room.spec.tsFile · 0.45
mainFunction · 0.45
ding-dong-bot.tsFile · 0.45

Calls 1

sendMethod · 0.95

Tested by

no test coverage detected