Class: ApnMachine::Server::ServerConnection
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- ApnMachine::Server::ServerConnection
- Defined in:
- lib/apnmachine/server/server_connection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #connection_completed ⇒ Object
-
#initialize(*args) ⇒ ServerConnection
constructor
A new instance of ServerConnection.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(*args) ⇒ ServerConnection
Returns a new instance of ServerConnection.
6 7 8 9 10 |
# File 'lib/apnmachine/server/server_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/apnmachine/server/server_connection.rb', line 4 def client @client end |
Instance Method Details
#connected? ⇒ Boolean
12 13 14 |
# File 'lib/apnmachine/server/server_connection.rb', line 12 def connected? !@disconnected end |
#connection_completed ⇒ Object
24 25 26 |
# File 'lib/apnmachine/server/server_connection.rb', line 24 def connection_completed Config.logger.info "Connection to Apple Servers completed" end |
#post_init ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/apnmachine/server/server_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/apnmachine/server/server_connection.rb', line 28 def receive_data(data) data_array = data.unpack("ccN") Config.logger.info "Error" error_response = ErrorResponse.new(*data_array) Config.logger.warn(error_response.to_s) if client.error_callback client.error_callback.call(error_response) end end |