lib/racoon/firehose.rb in racoon-0.6.0 vs lib/racoon/firehose.rb in racoon-1.0.0
- old
+ new
@@ -30,11 +30,11 @@
end
end
private
- def apns(project, bytes, retries=2)
+ def apns(project, bytes, retries=2, &error_callback)
uri = "gateway.#{project[:sandbox] ? 'sandbox.' : ''}push.apple.com"
hash = Digest::SHA1.hexdigest("#{project[:name]}-#{project[:certificate]}")
begin
@connections[hash] ||= { :connection => Racoon::APNS::Connection.new(project[:certificate], uri),
@@ -42,9 +42,10 @@
:sandbox => project[:sandbox] }
connection = @connections[hash][:connection]
connection.connect! unless connection.connected?
connection.write(bytes)
+ connection.read.each(&error_callback) unless error_callback.nil?
rescue Errno::EPIPE, OpenSSL::SSL::SSLError, Errno::ECONNRESET
connection.disconnect!
retry if (retries -= 1) > 0
end
end