Avoid re-opening connections after they're closed

This commit is contained in:
Jon Staab
2024-12-16 15:20:10 -08:00
parent 8825ed4d57
commit 887fbfc25d
9 changed files with 24 additions and 22 deletions
+5 -3
View File
@@ -44,11 +44,13 @@ export class Connection extends Emitter {
emit = (type: ConnectionEvent, ...args: any[]) => super.emit(type, this, ...args)
send = async (message: Message) => {
if (this.status !== Ready) {
throw new Error(`Attempted to send message on ${this.status} connection`)
}
await this.socket.open()
if (this.status === Ready) {
this.sender.push(message)
}
this.sender.push(message)
}
close = async () => {