lib/dashing/app.rb in smashing-1.3.3 vs lib/dashing/app.rb in smashing-1.3.4
- old
+ new
@@ -75,15 +75,15 @@
end
get '/events', :provides => 'text/event-stream' do
protected!
response.headers['X-Accel-Buffering'] = 'no' # Disable buffering for nginx
- ids = params[:ids].to_s.split(',').to_set
+ ids = params[:ids] ? params[:ids].split(',').to_set : nil
stream :keep_open do |out|
settings.connections[out] = ids
settings.history.each do |id, event|
- out << event if ids.include?(id)
+ out << event if ids.nil? || ids.include?(id)
end
out.callback { settings.connections.delete(out) }
end
end
@@ -147,10 +147,10 @@
body[:updatedAt] ||= (Time.now.to_f * 1000.0).to_i
event = format_event(body.to_json, target)
Sinatra::Application.settings.history[id] = event unless target == 'dashboards'
Sinatra::Application.settings.connections.each { |out, ids|
begin
- out << event if target == 'dashboards' || ids.include?(id)
+ out << event if target == 'dashboards' || ids.nil? || ids.include?(id)
rescue IOError => e # if the socket is closed an IOError is thrown
Sinatra::Application.settings.connections.delete(out)
end
}
end