lib/scamp/rooms.rb in scamp-1.0.0 vs lib/scamp/rooms.rb in scamp-1.0.1
- old
+ new
@@ -97,10 +97,16 @@
url = "https://streaming.campfirenow.com/room/#{room_id}/live.json"
# Timeout per https://github.com/igrigorik/em-http-request/wiki/Redirects-and-Timeouts
http = EventMachine::HttpRequest.new(url, :connect_timeout => 20, :inactivity_timeout => 0).get :head => {'authorization' => [api_key, 'X']}
http.errback { logger.error "Couldn't stream room #{room_id} at url #{url}" }
http.callback { logger.info "Disconnected from #{url}"; rooms_to_join << room_id}
- http.stream {|chunk| json_parser << chunk }
+ http.stream do |chunk|
+ begin
+ json_parser << chunk
+ rescue Yajl::ParseError => e
+ logger.error "Couldn't parse room data for room #{room_id} with url #{url}, http response data was #{chunk[0..50]}..."
+ end
+ end
end
def room_id_from_room_name(room_name)
logger.debug "Looking for room id for #{room_name}"
rooms[room_name]["id"]