Send sockets to listeners rather than urls

This commit is contained in:
Jonathan Staab
2023-07-27 08:40:39 -07:00
parent e9d7ad166e
commit ef18009d33
6 changed files with 37 additions and 27 deletions
+5 -3
View File
@@ -16,10 +16,10 @@ export class Pool extends EventEmitter {
const socket = new Socket(url)
this.data.set(url, socket)
this.emit('init', {url})
this.emit('init', socket)
socket.on('open', () => this.emit('open', {url}))
socket.on('close', () => this.emit('close', {url}))
socket.on('open', () => this.emit('open', socket))
socket.on('close', () => this.emit('close', socket))
}
return this.data.get(url)
@@ -28,7 +28,9 @@ export class Pool extends EventEmitter {
const socket = this.data.get(url)
if (socket) {
socket.disconnect()
socket.removeAllListeners()
this.data.delete(url)
}
}