Permalink
Browse files

Added message rebroadcast

  • Loading branch information...
1 parent 0ebf839 commit 8baaacbd10af422c93c9dd2bb755c12518955d87 @chemicaloliver committed Sep 7, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 app.js
View
6 app.js
@@ -52,15 +52,17 @@ http.createServer(function (request, response) {
// Handle WebSocket Requests
ws_server.addListener("connection", function(conn){
- conn.addListener("message", function(message){
- console.log(message);
+ conn.addListener("message", function(msg){
+ console.log('message');
+ conn.broadcast(msg);
});
});
ws_server.addListener("error", function(){
console.log(Array.prototype.join.call(arguments, ", "));
});
+
ws_server.addListener("disconnected", function(conn){
ws_server.broadcast("<"+conn.id+"> disconnected");
});

0 comments on commit 8baaacb

Please sign in to comment.