Class: Rpush::Daemon::Dispatcher::Apnsp8Http2

Inherits:
Object
  • Object
show all
Defined in:
lib/rpush/daemon/dispatcher/apnsp8_http2.rb

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(app, delivery_class, _options = {}) ⇒ Apnsp8Http2

Returns a new instance of Apnsp8Http2.



13
14
15
16
17
18
19
20
# File 'lib/rpush/daemon/dispatcher/apnsp8_http2.rb', line 13

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

Instance Method Details

#cleanupObject



27
28
29
# File 'lib/rpush/daemon/dispatcher/apnsp8_http2.rb', line 27

def cleanup
  @client.close
end

#dispatch(payload) ⇒ Object



22
23
24
25
# File 'lib/rpush/daemon/dispatcher/apnsp8_http2.rb', line 22

def dispatch(payload)

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