diff options
author | Minteck <nekostarfan@gmail.com> | 2021-04-30 19:58:12 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-04-30 19:58:12 +0200 |
commit | e0e892c709f844e3ddadd23db486ea480de6d9a7 (patch) | |
tree | 86967c6dd84f89880aa58e30d5f56a5ce332629d | |
parent | 0ef318f533ef86f6033b758f1850d24a065a7cc0 (diff) | |
download | kartik-legacy-server-e0e892c709f844e3ddadd23db486ea480de6d9a7.tar.gz kartik-legacy-server-e0e892c709f844e3ddadd23db486ea480de6d9a7.tar.bz2 kartik-legacy-server-e0e892c709f844e3ddadd23db486ea480de6d9a7.zip |
Fixes + more possibilities
-rw-r--r-- | index.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -58,7 +58,7 @@ class KartikError extends Error { const server = new Net.Server(); server.on('connection', (socket) => { - socket.connectionId = (Math.random().toString(16).split(".")[1] + Math.random().toString(16).split(".")[1]).substr(0, 8); + 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) @@ -254,6 +254,13 @@ server.on('connection', (socket) => { switch (info['_type']) { case "init": throw new KartikError("Trying to initialize client but client is already initialized", "net.minteckprojects.kartik.KartikServer.AuthenticationException"); + case "ping": + socket.write(JSON.stringify( + { + _type: "pong", + } + ) + "\n") + break; case "link": if (typeof info['client'] !== "string" || isNaN(parseInt(info['client'], 16))) { throw new KartikError("Invalid client link ID", "net.minteckprojects.kartik.KartikServer.GuestIdentifierException"); |