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
View File
@@ -3,14 +3,17 @@ import {Connection} from "./Connection"
export class Pool extends Emitter {
data: Map<string, Connection>
constructor() {
super()
this.data = new Map()
}
has(url: string) {
return this.data.has(url)
}
get(url: string): Connection {
const oldConnection = this.data.get(url)
@@ -25,6 +28,7 @@ export class Pool extends Emitter {
return newConnection
}
remove(url: string) {
const connection = this.data.get(url)
@@ -34,6 +38,7 @@ export class Pool extends Emitter {
this.data.delete(url)
}
}
clear() {
for (const url of this.data.keys()) {
this.remove(url)