Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed async bug with client

  • Loading branch information...
commit 6130b5e60846e269e90725348928586fc196bacf 1 parent 162c3bd
@olalonde authored
Showing with 13 additions and 12 deletions.
  1. +13 −12 ttychat.js
View
25 ttychat.js
@@ -13,18 +13,19 @@ var socket = new net.Socket({type: 'unix'});
socket.connect(socket_path, function() {
process.stdin.resume();
process.stdin.setEncoding('utf8');
- process.stdin.pipe(socket);
-});
-
-socket.on('data', function(data) {
- process.stdin.write(data);
-});
+
+ socket.on('data', function(data) {
+ process.stdin.write(data);
+ });
-socket.on('error', function(data) {
- process.stdin.write("Server is offline.");
-});
+ socket.on('error', function(data) {
+ process.stdin.write("Server is offline.");
+ });
-socket.on('end', function(data) {
- process.stdin.write("Disconnected from server.");
- process.exit();
+ socket.on('end', function(data) {
+ process.stdin.write("Disconnected from server.");
+ process.exit();
+ });
+
+ process.stdin.pipe(socket);
});
Please sign in to comment.
Something went wrong with that request. Please try again.