lib/sinatra-websocketio/websocketio.rb in sinatra-websocketio-0.3.9 vs lib/sinatra-websocketio/websocketio.rb in sinatra-websocketio-0.4.0
- old
+ new
@@ -52,10 +52,11 @@
end
end
end
def self.push(type, data, opt={})
- if opt.include? :to and self.sessions.include? opt[:to]
+ if opt.include? :to
+ return unless self.sessions.include? opt[:to]
s = self.sessions[opt[:to]][:websocket]
begin
s.send({:type => type, :data => data}.to_json)
rescue => e
emit :error, "websocketio push error (session:#{opt[:to]})"