Added broadcast feature.

This commit is contained in:
Martin Edenhofer 2012-10-29 00:47:38 +01:00
parent 28cdeed405
commit 6f4ee4c2bf

View file

@ -98,6 +98,14 @@ EventMachine.run {
elsif data['action'] == 'ping'
@clients[client_id][:last_ping] = Time.now
@clients[client_id][:websocket].send( '[{"action":"pong"}]' )
# broadcast
elsif data['action'] == 'broadcast'
@clients.each { |local_client_id, local_client|
if local_client_id != client_id
local_client[:websocket].send( "[#{msg}]" )
end
}
end
}
end