Fix some bugs with message delivery

This commit is contained in:
Jonathan Staab
2023-03-28 14:23:31 -05:00
parent 9b6a779397
commit 5a1a72491e
20 changed files with 275 additions and 224 deletions
+31
View File
@@ -0,0 +1,31 @@
import {Socket} from "./util/Socket"
export class Pool {
data: Map<string, Socket>
constructor() {
this.data = new Map()
}
has(url) {
return this.data.has(url)
}
get(url) {
if (!this.data.has(url)) {
this.data.set(url, new Socket(url))
}
return this.data.get(url)
}
remove(url) {
const socket = this.data.get(url)
if (socket) {
socket.disconnect()
this.data.delete(url)
}
}
clear() {
for (const url of this.data.keys()) {
this.remove(url)
}
}
}