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
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(host, port, pem) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 |
# File 'lib/mercurius/apns/connection.rb', line 7 def initialize(host, port, pem) @host = host @port = port @pem = pem end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/mercurius/apns/connection.rb', line 5 def host @host end |
#pem ⇒ Object (readonly)
Returns the value of attribute pem.
5 6 7 |
# File 'lib/mercurius/apns/connection.rb', line 5 def pem @pem end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/mercurius/apns/connection.rb', line 5 def port @port end |
Instance Method Details
#close ⇒ Object
19 20 21 22 |
# File 'lib/mercurius/apns/connection.rb', line 19 def close @ssl.close if @ssl @socket.close if @socket end |
#closed? ⇒ Boolean
24 25 26 |
# File 'lib/mercurius/apns/connection.rb', line 24 def closed? (@ssl.nil? || @ssl.closed?) && (@socket.nil? || @socket.closed?) end |
#open ⇒ Object
13 14 15 16 17 |
# File 'lib/mercurius/apns/connection.rb', line 13 def open @socket = TCPSocket.new host, port @ssl = OpenSSL::SSL::SSLSocket.new @socket, ssl_context_for_pem(pem) @ssl.connect end |
#read ⇒ Object
32 33 34 |
# File 'lib/mercurius/apns/connection.rb', line 32 def read @ssl.read end |
#write(data) ⇒ Object
28 29 30 |
# File 'lib/mercurius/apns/connection.rb', line 28 def write(data) @ssl.write data end |