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 ⇒ 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.
7 8 9 10 11 12 |
# File 'lib/bmo/apns/connection.rb', line 7 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.
5 6 7 |
# File 'lib/bmo/apns/connection.rb', line 5 def cert_pass @cert_pass end |
#cert_path ⇒ Object (readonly)
Returns the value of attribute cert_path.
5 6 7 |
# File 'lib/bmo/apns/connection.rb', line 5 def cert_path @cert_path end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/bmo/apns/connection.rb', line 5 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/bmo/apns/connection.rb', line 5 def port @port end |
Instance Method Details
#connect ⇒ 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
18 19 20 21 22 23 24 25 |
# File 'lib/bmo/apns/connection.rb', line 18 def connect socket = cert_path ? ssl_socket : tcp_socket yielded = yield socket socket.close yielded end |