Class: ApnsDispatch::ApnsConnection
- Inherits:
-
Object
- Object
- ApnsDispatch::ApnsConnection
- Defined in:
- lib/apns_dispatch/apns_connection.rb
Overview
Handles communication with the Apple Push Notification service (APNs). Based on code from github.com/itspriddle/apnd.
Constant Summary collapse
- FEEDBACK_PORT =
Constants
2196
- GATEWAY_PORT =
2195
- PRODUCTION_FEEDBACK_HOST =
'feedback.push.apple.com'
- PRODUCTION_GATEWAY_HOST =
'gateway.push.apple.com'
- RETRYABLE_ERRORS =
[Errno::EPIPE, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError]
- SANDBOX_FEEDBACK_HOST =
'feedback.sandbox.push.apple.com'
- SANDBOX_GATEWAY_HOST =
'gateway.sandbox.push.apple.com'
Instance Attribute Summary collapse
-
#certificate ⇒ Object
readonly
Attributes.
-
#host ⇒ Object
readonly
Attributes.
-
#options ⇒ Object
readonly
Attributes.
-
#port ⇒ Object
readonly
Attributes.
Instance Method Summary collapse
-
#initialize(certificate, options = {}) ⇒ ApnsConnection
constructor
A new instance of ApnsConnection.
- #read(length) ⇒ Object
- #write(message) ⇒ Object
Constructor Details
#initialize(certificate, options = {}) ⇒ ApnsConnection
Returns a new instance of ApnsConnection.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/apns_dispatch/apns_connection.rb', line 22 def initialize(certificate, ={}) if [:feedback] @port = FEEDBACK_PORT if [:production] @host = PRODUCTION_FEEDBACK_HOST else @host = SANDBOX_FEEDBACK_HOST end else @port = GATEWAY_PORT if [:production] @host = PRODUCTION_GATEWAY_HOST else @host = SANDBOX_GATEWAY_HOST end end @certificate = certificate @options = @mutex = Mutex.new end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Attributes
20 21 22 |
# File 'lib/apns_dispatch/apns_connection.rb', line 20 def certificate @certificate end |
#host ⇒ Object (readonly)
Attributes
20 21 22 |
# File 'lib/apns_dispatch/apns_connection.rb', line 20 def host @host end |
#options ⇒ Object (readonly)
Attributes
20 21 22 |
# File 'lib/apns_dispatch/apns_connection.rb', line 20 def @options end |
#port ⇒ Object (readonly)
Attributes
20 21 22 |
# File 'lib/apns_dispatch/apns_connection.rb', line 20 def port @port end |
Instance Method Details
#read(length) ⇒ Object
46 47 48 |
# File 'lib/apns_dispatch/apns_connection.rb', line 46 def read(length) with_connection { @ssl.read(length) } end |
#write(message) ⇒ Object
50 51 52 |
# File 'lib/apns_dispatch/apns_connection.rb', line 50 def write() with_connection { @ssl.write() } end |