Skip to content

Commit

Permalink
remove old input line after message entered
Browse files Browse the repository at this point in the history
  • Loading branch information
aviaryan committed Feb 9, 2018
1 parent 2cf0858 commit 76a7175
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
});
};
Expand Down

0 comments on commit 76a7175

Please sign in to comment.