Class: Rpush::Daemon::Dispatcher::ApnsHttp2
- Inherits:
-
Object
- Object
- Rpush::Daemon::Dispatcher::ApnsHttp2
- Defined in:
- lib/rpush/daemon/dispatcher/apns_http2.rb
Constant Summary collapse
- URLS =
{ production: 'https://api.push.apple.com:443', development: 'https://api.development.push.apple.com:443' }
- DEFAULT_TIMEOUT =
60
Instance Method Summary collapse
- #cleanup ⇒ Object
- #dispatch(payload) ⇒ Object
-
#initialize(app, delivery_class, _options = {}) ⇒ ApnsHttp2
constructor
A new instance of ApnsHttp2.
Constructor Details
#initialize(app, delivery_class, _options = {}) ⇒ ApnsHttp2
Returns a new instance of ApnsHttp2.
13 14 15 16 17 18 19 20 21 |
# File 'lib/rpush/daemon/dispatcher/apns_http2.rb', line 13 def initialize(app, delivery_class, = {}) @app = app @delivery_class = delivery_class url = URLS[app.environment.to_sym] @client = NetHttp2::Client.new(url, ssl_context: prepare_ssl_context, connect_timeout: DEFAULT_TIMEOUT) end |
Instance Method Details
#cleanup ⇒ Object
27 28 29 |
# File 'lib/rpush/daemon/dispatcher/apns_http2.rb', line 27 def cleanup @client.close end |
#dispatch(payload) ⇒ Object
23 24 25 |
# File 'lib/rpush/daemon/dispatcher/apns_http2.rb', line 23 def dispatch(payload) @delivery_class.new(@app, @client, payload.batch).perform end |