Permalink
Browse files

connect now an event

  • Loading branch information...
1 parent 905afe5 commit 6d0a0100b0ec0aefa2f5e818174d2ceca4079ea7 @olalonde committed Mar 31, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 ttychat.js
View
@@ -14,6 +14,12 @@ socket.on('data', function(data) {
process.stdin.write(data);
});
+socket.on('connect', function(data) {
+ process.stdin.resume();
+ process.stdin.setEncoding('utf8');
+ process.stdin.pipe(socket);
+});
+
socket.on('error', function(data) {
process.stdin.write("Server is offline.");
});
@@ -23,9 +29,4 @@ socket.on('end', function(data) {
process.exit();
});
-socket.connect(socket_path, function() {
- process.stdin.resume();
- process.stdin.setEncoding('utf8');
-
- process.stdin.pipe(socket);
-});
+socket.connect(socket_path, function() {});

0 comments on commit 6d0a010

Please sign in to comment.