Permalink
Browse files

tryin to fix bug

  • Loading branch information...
1 parent 6130b5e commit 905afe57be8cf377e363cc5b3b16a50d02dc903d @olalonde committed Mar 31, 2011
Showing with 13 additions and 13 deletions.
  1. +13 −13 ttychat.js
View
@@ -10,22 +10,22 @@ var socket_path = "/tmp/ttychat.sock";
var socket = new net.Socket({type: 'unix'});
+socket.on('data', function(data) {
+ process.stdin.write(data);
+});
+
+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.connect(socket_path, function() {
process.stdin.resume();
process.stdin.setEncoding('utf8');
- socket.on('data', function(data) {
- process.stdin.write(data);
- });
-
- socket.on('error', function(data) {
- process.stdin.write("Server is offline.");
- });
-
- socket.on('end', function(data) {
- process.stdin.write("Disconnected from server.");
- process.exit();
- });
-
process.stdin.pipe(socket);
});

0 comments on commit 905afe5

Please sign in to comment.