Sha256: 637dba013bfd3b46956f1b80ab26bb5d21c93e4976adaa6f3a63bf098a888fe6

Contents?: true

Size: 940 Bytes

Versions: 12

Compression:

Stored size: 940 Bytes

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 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

12 entries across 12 versions & 1 rubygems

Version Path
rpush-2.2.0-java lib/rpush/daemon/apns/delivery.rb
rpush-2.2.0 lib/rpush/daemon/apns/delivery.rb
rpush-2.1.0-java lib/rpush/daemon/apns/delivery.rb
rpush-2.1.0 lib/rpush/daemon/apns/delivery.rb
rpush-2.0.1-java lib/rpush/daemon/apns/delivery.rb
rpush-2.0.1 lib/rpush/daemon/apns/delivery.rb
rpush-2.0.0-java lib/rpush/daemon/apns/delivery.rb
rpush-2.0.0 lib/rpush/daemon/apns/delivery.rb
rpush-2.0.0.rc1-java lib/rpush/daemon/apns/delivery.rb
rpush-2.0.0.rc1 lib/rpush/daemon/apns/delivery.rb
rpush-2.0.0.beta2 lib/rpush/daemon/apns/delivery.rb
rpush-2.0.0.beta1 lib/rpush/daemon/apns/delivery.rb