18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/sinatra/multi_screen.rb', line 18
def self.push(event, data, opts={})
ids = nil
channel = opts[:channel].to_s
type = opts[:type].to_s
if !channel.empty? and !type.empty?
ids = channels[channel][type] or []
elsif !channel.empty?
ids = channels[channel].values.flatten or []
elsif !type.empty?
ids = channels.values.map{|i| i[type] }.flatten or []
else
ids = channels.values.map{|i| i.values }.flatten or []
end
ids.each do |session_id|
CometIO.push(:__multiscreen__server,
{:event => event, :data => data},
{:to => session_id})
end
end
|