From 2ea89f09b5d74807089f624530067ab69caeabce Mon Sep 17 00:00:00 2001 From: jsrobson10 Date: Sat, 30 Mar 2019 21:27:36 +1100 Subject: [PATCH] Made the communication even more stable, fixed bugs with modified client. --- main.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index ae19f31..3cb27b4 100644 --- a/main.js +++ b/main.js @@ -115,6 +115,8 @@ function socket_init(socket, callback, ondata) sock.sock = socket; sock.new = true; + console.log("Connection from "+socket.localAdress); + // Wait for data sock.sock.on('data', function(data) { @@ -144,15 +146,18 @@ function socket_init(socket, callback, ondata) console.log("Encrypted the key"); // Send the size of the key to the client - sock.sock.write(key_encrypted.length.toString()); + sock.sock.write(key_encrypted.length.toString()+"\n"); console.log("Sent the size of the key:", key_encrypted.length) // Send the key to the client - sock.sock.write(key_encrypted.toString()); + sock.sock.write(key_encrypted.toString()+"\n"); console.log("Sent the key to the client"); + // Send the done signal + //sock.sock.write("done"+"\n"); + // Call the callback - setTimeout(callback, 10, sock); + setTimeout(callback, 1000, sock); }); } @@ -168,6 +173,7 @@ function socket_init(socket, callback, ondata) for(var i=0;i