Class: BMO::APNS::Connection
- Inherits:
-
Object
- Object
- BMO::APNS::Connection
- Defined in:
- lib/bmo/apns/connection.rb
Overview
Handle the connection state SSL or Pure TCP
Instance Attribute Summary collapse
-
#cert_pass ⇒ Object
readonly
Returns the value of attribute cert_pass.
-
#cert_path ⇒ Object
readonly
Returns the value of attribute cert_path.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#connect(&block) ⇒ Object
Create a connection to Apple.
-
#initialize(host, port, cert_path = nil, cert_pass = nil) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(host, port, cert_path = nil, cert_pass = nil) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 13 |
# File 'lib/bmo/apns/connection.rb', line 8 def initialize(host, port, cert_path = nil, cert_pass = nil) @host = host @port = port @cert_path = cert_path @cert_pass = cert_pass end |
Instance Attribute Details
#cert_pass ⇒ Object (readonly)
Returns the value of attribute cert_pass.
6 7 8 |
# File 'lib/bmo/apns/connection.rb', line 6 def cert_pass @cert_pass end |
#cert_path ⇒ Object (readonly)
Returns the value of attribute cert_path.
6 7 8 |
# File 'lib/bmo/apns/connection.rb', line 6 def cert_path @cert_path end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/bmo/apns/connection.rb', line 6 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/bmo/apns/connection.rb', line 6 def port @port end |
Instance Method Details
#connect(&block) ⇒ Object
Create a connection to Apple. If a cert_path exists it uses SSL else
a pure TCPSocket. It then yields the socket and handles the closing
19 20 21 22 23 24 25 26 |
# File 'lib/bmo/apns/connection.rb', line 19 def connect(&block) socket = cert_path ? ssl_socket : tcp_socket yielded = yield socket socket.close yielded end |