Fix server not correctly removing clients (#588)

* Properly remove connection from clients list

* Changed misname in onCloseConnection

* Update server.js fix

---------

Co-authored-by: JSbETms <137791538+JSbETms@users.noreply.github.com>
Co-authored-by: extremeheat <extreme@protonmail.ch>
This commit is contained in:
EntifiedOptics 2025-03-18 21:01:49 +00:00 committed by GitHub
commit 47f342ca95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,12 +89,10 @@ class Server extends EventEmitter {
this.emit('connect', player)
}
onCloseConnection = (inetAddr, reason) => {
this.conLog('Connection closed: ', inetAddr?.address, reason)
delete this.clients[inetAddr]?.connection // Prevent close loop
this.clients[inetAddr?.address ?? inetAddr]?.close()
delete this.clients[inetAddr]
onCloseConnection = (conn, reason) => {
this.conLog('Connection closed: ', conn.address, reason)
this.clients[conn.address]?.close()
delete this.clients[conn.address]
this.clientCount--
}