Added broadcast feature.
This commit is contained in:
parent
28cdeed405
commit
6f4ee4c2bf
1 changed files with 8 additions and 0 deletions
|
@ -98,6 +98,14 @@ EventMachine.run {
|
||||||
elsif data['action'] == 'ping'
|
elsif data['action'] == 'ping'
|
||||||
@clients[client_id][:last_ping] = Time.now
|
@clients[client_id][:last_ping] = Time.now
|
||||||
@clients[client_id][:websocket].send( '[{"action":"pong"}]' )
|
@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
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue