lib/sinatra/cometio/client.rb in sinatra-cometio-0.1.9 vs lib/sinatra/cometio/client.rb in sinatra-cometio-0.2.0

- old
+ new

@@ -52,11 +52,14 @@ unless res.code == 200 self.emit :error, "CometIO get error" sleep 10 next else - data = JSON.parse res.body - self.emit data['type'], data['data'] + data_arr = JSON.parse res.body + data_arr = [data_arr] unless data_arr.kind_of? Array + data_arr.each do |data| + self.emit data['type'], data['data'] + end next end rescue Timeout::Error, JSON::ParserError next rescue StandardError