feat: 优化websocket

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2021-10-25 15:56:23 +08:00
parent cf9153c134
commit 476d98b9c7
5 changed files with 9 additions and 7 deletions

View File

@@ -57,6 +57,8 @@ export abstract class Transport extends EventEmitter {
this.doClose(code, reason)
} catch (error) {
this.onerror({ error })
} finally {
this.removeAllListeners()
}
} else {
console.debug(`${this.id} call close but state is ${this.readyStatus}`)
@@ -69,7 +71,6 @@ export abstract class Transport extends EventEmitter {
}
onconnect(event: Event) {
console.debug(`${this.id} call onconnect`)
if (this.readyStatus != WebSocket.OPEN) {
this.readyStatus = WebSocket.OPEN
this.emit('open', event)