Skip to content
Browse files

tweaking message output

  • Loading branch information...
1 parent 60b65d7 commit b9f38f7b983c6787965316cf02b7feabc8cda3b1 @remy committed Apr 17, 2011
Showing with 5 additions and 8 deletions.
  1. +3 −3 public/index.html
  2. +2 −5 server.js
View
6 public/index.html
@@ -256,7 +256,7 @@
function connect() {
log('Connecting...');
- socket = new WebSocket('ws://localhost:8000');
+ socket = new WebSocket('ws://' + location.host);
socket.onopen = function () {
log('Connected');
@@ -267,12 +267,12 @@
};
socket.onmessage = function (event) {
- log('Message: ' + event.data);
+ log('\u00BB ' + event.data);
};
message.form.onsubmit = function () {
if (socket.readyState == 1) {
- log('Sending: "' + message.value + '"');
+ log('\u00AB "' + message.value + '"');
socket.send(message.value);
window.location.hash = this.id;
}
View
7 server.js
@@ -40,20 +40,17 @@ socket.addListener('listening', function(){
// Handle WebSocket Requests
socket.addListener('connection', function(conn){
- console.log('CONNECTION!');
socket.send(conn.id, connected+'');
- socket.broadcast(connected+'');
+ socket.broadcast('Connected users: ' + connected);
conn.addListener('message', function(message){
- console.log('MESSAGE IN!');
socket.broadcast(message);
});
});
socket.addListener('close', function(conn){
connected--;
- console.log('CLOSED!');
- conn.broadcast(connected+'');
+ socket.broadcast('User left, connected now: ' + connected);
});
console.log('Listening on ' + (process.ARGV[2] || 80));

0 comments on commit b9f38f7

Please sign in to comment.
Something went wrong with that request. Please try again.