Wait for disconnect before removing listeners on connection

This commit is contained in:
Jon Staab
2024-10-30 13:26:04 -07:00
parent da3379bca3
commit c93d102c08
3 changed files with 10 additions and 6 deletions
+6 -4
View File
@@ -117,15 +117,17 @@ export class Connection extends Emitter {
}
}
disconnect() {
this.socket.disconnect()
async disconnect() {
await this.socket.disconnect()
this.sender.clear()
this.receiver.clear()
this.meta.clearPending()
}
destroy() {
this.disconnect()
async destroy() {
await this.disconnect()
this.removeAllListeners()
this.sender.stop()
this.receiver.stop()