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'
- 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.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/apns_dispatch/apns_connection.rb', line 21 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 = end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Attributes
19 20 21 |
# File 'lib/apns_dispatch/apns_connection.rb', line 19 def certificate @certificate end |
#host ⇒ Object (readonly)
Attributes
19 20 21 |
# File 'lib/apns_dispatch/apns_connection.rb', line 19 def host @host end |
#options ⇒ Object (readonly)
Attributes
19 20 21 |
# File 'lib/apns_dispatch/apns_connection.rb', line 19 def @options end |
#port ⇒ Object (readonly)
Attributes
19 20 21 |
# File 'lib/apns_dispatch/apns_connection.rb', line 19 def port @port end |
Instance Method Details
#read(length) ⇒ Object
44 45 46 |
# File 'lib/apns_dispatch/apns_connection.rb', line 44 def read(length) with_connection { @ssl.read(length) } end |
#write(message) ⇒ Object
48 49 50 |
# File 'lib/apns_dispatch/apns_connection.rb', line 48 def write() with_connection { @ssl.write() } end |