Class: APNS::Connection
- Inherits:
-
Object
- Object
- APNS::Connection
- Defined in:
- lib/mercurius/apns/connection.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#pem ⇒ Object
readonly
Returns the value of attribute pem.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(host, port, pem) ⇒ Connection
constructor
A new instance of Connection.
- #open ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(host, port, pem) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 9 |
# File 'lib/mercurius/apns/connection.rb', line 5 def initialize(host, port, pem) @host = host @port = port @pem = pem end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/mercurius/apns/connection.rb', line 3 def host @host end |
#pem ⇒ Object (readonly)
Returns the value of attribute pem.
3 4 5 |
# File 'lib/mercurius/apns/connection.rb', line 3 def pem @pem end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/mercurius/apns/connection.rb', line 3 def port @port end |
Instance Method Details
#close ⇒ Object
17 18 19 20 |
# File 'lib/mercurius/apns/connection.rb', line 17 def close @ssl.close if @ssl @socket.close if @socket end |
#closed? ⇒ Boolean
22 23 24 |
# File 'lib/mercurius/apns/connection.rb', line 22 def closed? (@ssl.nil? || @ssl.closed?) || (@socket.nil? || @socket.closed?) end |
#open ⇒ Object
11 12 13 14 15 |
# File 'lib/mercurius/apns/connection.rb', line 11 def open @socket ||= TCPSocket.new host, port @ssl ||= OpenSSL::SSL::SSLSocket.new @socket, ssl_context_for_pem(pem) @ssl.connect end |
#write(data) ⇒ Object
26 27 28 |
# File 'lib/mercurius/apns/connection.rb', line 26 def write(data) @ssl.write data end |