implement TCP server, reimplement maxConnections except it now kicks the oldest connection

This commit is contained in:
Elijah R
2024-05-27 00:06:05 -04:00
parent 7053973205
commit 8add016b60
7 changed files with 115 additions and 6 deletions

View File

@@ -6,13 +6,11 @@ import { Logger } from "@cvmts/shared";
export default class WSClient extends EventEmitter implements NetworkClient {
socket: WebSocket;
ip: string;
logger: Logger;
constructor(ws: WebSocket, ip: string) {
super();
this.socket = ws;
this.ip = ip;
this.logger = new Logger("CVMTS.WSClient");
this.socket.on('message', (buf: Buffer, isBinary: boolean) => {
// Close the user's connection if they send a non-string message
if (isBinary) {
@@ -25,7 +23,6 @@ export default class WSClient extends EventEmitter implements NetworkClient {
this.socket.on('close', () => {
this.emit('disconnect');
});
}