Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tryin to fix bug

  • Loading branch information...
commit 905afe57be8cf377e363cc5b3b16a50d02dc903d 1 parent 6130b5e
@olalonde authored
Showing with 13 additions and 13 deletions.
  1. +13 −13 ttychat.js
View
26 ttychat.js
@@ -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);
});
Please sign in to comment.
Something went wrong with that request. Please try again.