From 76a7175d46b97b9a0a546d6ee9dba7adaf964e04 Mon Sep 17 00:00:00 2001 From: Avi Aryan Date: Fri, 9 Feb 2018 20:07:19 +0530 Subject: [PATCH] remove old input line after message entered --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5fc12bb..67fab35 100644 --- a/index.js +++ b/index.js @@ -46,7 +46,7 @@ socket.on('connect', () => { getUserAndJoin(); } else if (msg.type === 'joined') { // listener for messages - socket.on('/msg test', function (msg) { + socket.on('/msg ' + channel, function (msg) { if (msg.user === null) { console.log(`[ ${msg.data} ]`); } else { @@ -56,7 +56,9 @@ socket.on('connect', () => { // get user input messages let getInput = () => { rl.question('', (inp) => { - socket.emit('/msg test', { user: user, data: inp }); + socket.emit('/msg ' + channel, { user: user, data: inp }); + // https://stackoverflow.com/questions/45147470/ + readline.moveCursor(process.stdout, 0, -1); getInput(); }); };