aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-04-30 19:58:12 +0200
committerMinteck <nekostarfan@gmail.com>2021-04-30 19:58:12 +0200
commite0e892c709f844e3ddadd23db486ea480de6d9a7 (patch)
tree86967c6dd84f89880aa58e30d5f56a5ce332629d
parent0ef318f533ef86f6033b758f1850d24a065a7cc0 (diff)
downloadkartik-legacy-server-e0e892c709f844e3ddadd23db486ea480de6d9a7.tar.gz
kartik-legacy-server-e0e892c709f844e3ddadd23db486ea480de6d9a7.tar.bz2
kartik-legacy-server-e0e892c709f844e3ddadd23db486ea480de6d9a7.zip
Fixes + more possibilities
-rw-r--r--index.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/index.js b/index.js
index d4db372..4453820 100644
--- a/index.js
+++ b/index.js
@@ -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");