Permalink
Browse files

added global channel

  • Loading branch information...
1 parent b42305d commit c16326f472459f0e0e48e9834d56ba76710a3595 Plank Multimedia committed Apr 5, 2012
Showing with 12 additions and 6 deletions.
  1. +9 −6 lib/connection_manager.rb
  2. +3 −0 public/eventchat.js
View
@@ -17,15 +17,18 @@ def remove_room(room)
end
def add_socket(socket)
- puts "Adding socket to pool"
- token = socket.request['query']['auth']
- @sockets[token] = socket
+ puts "Adding socket to pool: #{socket.signature}"
+ @global.subscribe do |msg|
+ socket.send(msg)
+ end
+ @global.push("#{socket.signature} connected")
+ @sockets[socket.signature] = socket
end
def remove_socket(socket)
- puts "Removing socket from pool"
- token = socket.request['query']['auth']
- @sockets.delete(token)
+ puts "Removing socket from pool: #{socket.signature}"
+ @sockets.delete(socket.signature)
+ @global.push("#{socket.signature} disconnected")
end
def process_message(socket, msg)
View
@@ -7,6 +7,9 @@ $(document).ready(function() {
e.preventDefault();
var path = $('#token').val();
ws = new WebSocket('ws://localhost:8080/?auth='+path);
+ ws.onmessage = function(msg) {
+ console.log(msg);
+ }
});
$('#send').click(function(e) {

0 comments on commit c16326f

Please sign in to comment.