diff options
author | Minteck <nekostarfan@gmail.com> | 2021-04-30 20:00:09 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-04-30 20:00:09 +0200 |
commit | f72770f62a1bde2b92d83561853f8996a48fd0e3 (patch) | |
tree | 7cd71776109974c1b093c77f457b413e51614967 | |
parent | e0e892c709f844e3ddadd23db486ea480de6d9a7 (diff) | |
download | kartik-legacy-server-f72770f62a1bde2b92d83561853f8996a48fd0e3.tar.gz kartik-legacy-server-f72770f62a1bde2b92d83561853f8996a48fd0e3.tar.bz2 kartik-legacy-server-f72770f62a1bde2b92d83561853f8996a48fd0e3.zip |
Another fix
-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", |