lib/dashing/app.rb in smashing-1.3.0 vs lib/dashing/app.rb in smashing-1.3.1
- old
+ new
@@ -142,10 +142,16 @@
def send_event(id, body, target=nil)
body[:id] = id
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| out << event }
+ Sinatra::Application.settings.connections.each { |out|
+ begin
+ out << event
+ rescue IOError => e # if the socket is closed an IOError is thrown
+ Sinatra::Application.settings.connections.delete(out)
+ end
+ }
end
def format_event(body, name=nil)
str = ""
str << "event: #{name}\n" if name