aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/index.js b/index.js
index 4453820..86091c1 100644
--- a/index.js
+++ b/index.js
@@ -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",