diff options
-rw-r--r-- | index.js | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -59,10 +59,17 @@ const server = new Net.Server(); server.on('connection', (socket) => { socket.connectionId = (Math.random().toString(36).split(".")[1] + Math.random().toString(36).split(".")[1]).substr(0, 8); + while (Object.keys(clients).includes(socket.connectionId)) { + socket.connectionId = (Math.random().toString(36).split(".")[1] + Math.random().toString(36).split(".")[1]).substr(0, 8); + } socket.linkedTo = null; clients[socket.connectionId] = socket; console.log("New connection " + socket.connectionId) + if (clients.length > 280) { + throw new KartikError("Server is full", "net.minteckprojects.kartik.KartikServer.IdentifierAllocationException"); + } + socket.write(JSON.stringify( { _type: "init", |