Class: EventMachine::APN::Connection
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- EventMachine::APN::Connection
- Defined in:
- lib/em-apn/connection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #disconnected? ⇒ Boolean
-
#initialize(*args) ⇒ Connection
constructor
A new instance of Connection.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(*args) ⇒ Connection
Returns a new instance of Connection.
6 7 8 9 10 |
# File 'lib/em-apn/connection.rb', line 6 def initialize(*args) super @client = args.last @disconnected = false end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/em-apn/connection.rb', line 4 def client @client end |
Instance Method Details
#connection_completed ⇒ Object
24 25 26 |
# File 'lib/em-apn/connection.rb', line 24 def connection_completed EM::APN.logger.info("Connection completed") end |
#disconnected? ⇒ Boolean
12 13 14 |
# File 'lib/em-apn/connection.rb', line 12 def disconnected? @disconnected end |
#post_init ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/em-apn/connection.rb', line 16 def post_init start_tls( :private_key_file => client.key, :cert_chain_file => client.cert, :verify_peer => false ) end |
#receive_data(data) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/em-apn/connection.rb', line 28 def receive_data(data) data_array = data.unpack("ccN") error_response = ErrorResponse.new(*data_array) EM::APN.logger.warn(error_response.to_s) if client.error_callback client.error_callback.call(error_response) end end |
#unbind ⇒ Object
38 39 40 41 42 43 |
# File 'lib/em-apn/connection.rb', line 38 def unbind @disconnected = true EM::APN.logger.info("Connection closed") client.close_callback.call if client.close_callback end |