Sha256: e8b9d450cf5bcd8f08c10bce7256db973e7c0fc790cf3838d3f0dc44cceb9067

Contents?: true

Size: 792 Bytes

Versions: 9

Compression:

Stored size: 792 Bytes

Contents

module Rpush
  module Daemon
    module Dispatcher
      class Apnsp8Http2

        URLS = {
          production: 'https://api.push.apple.com',
          development: 'https://api.development.push.apple.com'
        }

        DEFAULT_TIMEOUT = 60

        def initialize(app, delivery_class, _options = {})
          @app = app
          @delivery_class = delivery_class

          url = URLS[app.environment.to_sym]
          @client = NetHttp2::Client.new(url, connect_timeout: DEFAULT_TIMEOUT)
          @token_provider = Rpush::Daemon::Apnsp8::Token.new(@app)
        end

        def dispatch(payload)

          @delivery_class.new(@app, @client, @token_provider, payload.batch).perform
        end

        def cleanup
          @client.close
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
rpush-3.3.1 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush-3.3.0 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush_extended-3.2.6 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush_extended-3.2.5 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush-3.2.4 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush-3.2.3 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush-3.2.2 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush-3.2.1 lib/rpush/daemon/dispatcher/apnsp8_http2.rb
rpush-3.2.0 lib/rpush/daemon/dispatcher/apnsp8_http2.rb