Sha256: 07c4b0fdeb52309c4d36e5ecdf199da9af02690aea34d4dee2fde0341ecff183

Contents?: true

Size: 1.05 KB

Versions: 44

Compression:

Stored size: 1.05 KB

Contents

module Rpush
  module Daemon
    module Apns
      class Delivery < Rpush::Daemon::Delivery
        def initialize(app, connection, batch)
          @app = app
          @connection = connection
          @batch = batch
        end

        def perform
          @connection.write(batch_to_binary)
          mark_batch_delivered
          describe_deliveries
        rescue Rpush::Daemon::TcpConnectionError => error
          mark_batch_retryable(Time.now + 10.seconds, error)
          raise
        rescue StandardError => error
          mark_batch_failed(error)
          raise
        ensure
          @batch.all_processed
        end

        protected

        def batch_to_binary
          payload = ""
          @batch.each_notification do |notification|
            payload << notification.to_binary
          end
          payload
        end

        def describe_deliveries
          @batch.each_notification do |notification|
            log_info("#{notification.id} sent to #{notification.device_token}")
          end
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
rpush-8.0.0 lib/rpush/daemon/apns/delivery.rb
rpush-7.0.1 lib/rpush/daemon/apns/delivery.rb
rpush-7.0.0 lib/rpush/daemon/apns/delivery.rb
rpush-6.0.1 lib/rpush/daemon/apns/delivery.rb
rpush-6.0.0 lib/rpush/daemon/apns/delivery.rb
rpush-5.4.0 lib/rpush/daemon/apns/delivery.rb
rpush-5.3.0 lib/rpush/daemon/apns/delivery.rb
rpush-5.2.0 lib/rpush/daemon/apns/delivery.rb
rpush-5.1.0 lib/rpush/daemon/apns/delivery.rb
rpush-5.0.0 lib/rpush/daemon/apns/delivery.rb
rpush-4.2.0 lib/rpush/daemon/apns/delivery.rb
rpush-4.1.1 lib/rpush/daemon/apns/delivery.rb
rpush-4.1.0 lib/rpush/daemon/apns/delivery.rb
rpush-4.0.1 lib/rpush/daemon/apns/delivery.rb
rpush-4.0.0 lib/rpush/daemon/apns/delivery.rb
rpush-3.3.1 lib/rpush/daemon/apns/delivery.rb
rpush-3.3.0 lib/rpush/daemon/apns/delivery.rb
rpush_extended-3.2.6 lib/rpush/daemon/apns/delivery.rb
rpush_extended-3.2.5 lib/rpush/daemon/apns/delivery.rb
rpush-3.2.4 lib/rpush/daemon/apns/delivery.rb