Skip to content

Instantly share code, notes, and snippets.

@Azerothian
Created May 7, 2010 03:31
Show Gist options
  • Save Azerothian/393011 to your computer and use it in GitHub Desktop.
Save Azerothian/393011 to your computer and use it in GitHub Desktop.
var server = tcp.createServer(function (stream) {
stream.setEncoding('utf8');
stream.setTimeout(0);
var user = new User(stream);
Users.push(user);
stream.addListener('connect', function () {
debug("Connection " + stream.remoteAddress);
user.OnConnect();
});
stream.addListener('data', function (data) {
debug("Recieve " + stream.remoteAddress + "::"+data);
user.OnRecieve(data);
});
stream.addListener('end', function () {
debug("Disconnect " + stream.remoteAddress);
user.OnDisconnect();
//stream.write('goodbye\r\n');
//stream.end();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment