-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.js
More file actions
31 lines (25 loc) · 687 Bytes
/
client.js
File metadata and controls
31 lines (25 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var io = require('socket.io-client');
var socket = io('http://localhost:3000');
socket.on('connect', function () {
console.log('got connected');
cli();
});
// ************************ functions ******************************************
function cli () {
process.stdin.resume();
process.stdin.setEncoding('utf8');
var util = require('util');
process.stdin.on('data', function (text) {
console.log('received data:', util.inspect(text));
if (text === 'quit\n') {
done();
}
else {
socket.emit()
}
});
function done() {
console.log('Now that process.stdin is paused, there is nothing more to do.');
process.exit();
}
}