Class: ApnMachine::Server::Client
- Inherits:
-
Object
- Object
- ApnMachine::Server::Client
- Defined in:
- lib/apnmachine/server/client.rb
Instance Attribute Summary collapse
-
#apn_host ⇒ Object
Returns the value of attribute apn_host.
-
#apn_port ⇒ Object
Returns the value of attribute apn_port.
-
#cert ⇒ Object
Returns the value of attribute cert.
-
#close_callback ⇒ Object
Returns the value of attribute close_callback.
-
#key ⇒ Object
Returns the value of attribute key.
-
#password ⇒ Object
Returns the value of attribute password.
-
#pem ⇒ Object
Returns the value of attribute pem.
Instance Method Summary collapse
- #connect! ⇒ Object
- #connected? ⇒ Boolean
- #disconnect! ⇒ Object
-
#initialize(pem, password = nil, apn_host = 'gateway.push.apple.com', apn_port = 2195) ⇒ Client
constructor
A new instance of Client.
- #on_close(&block) ⇒ Object
- #on_error(&block) ⇒ Object
- #write(notif_bin) ⇒ Object
Constructor Details
#initialize(pem, password = nil, apn_host = 'gateway.push.apple.com', apn_port = 2195) ⇒ Client
Returns a new instance of Client.
6 7 8 |
# File 'lib/apnmachine/server/client.rb', line 6 def initialize(pem, password = nil, apn_host = 'gateway.push.apple.com', apn_port = 2195) @pem, @pasword, @apn_host, @apn_port = pem, password, apn_host, apn_port end |
Instance Attribute Details
#apn_host ⇒ Object
Returns the value of attribute apn_host.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def apn_host @apn_host end |
#apn_port ⇒ Object
Returns the value of attribute apn_port.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def apn_port @apn_port end |
#cert ⇒ Object
Returns the value of attribute cert.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def cert @cert end |
#close_callback ⇒ Object
Returns the value of attribute close_callback.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def close_callback @close_callback end |
#key ⇒ Object
Returns the value of attribute key.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def key @key end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def password @password end |
#pem ⇒ Object
Returns the value of attribute pem.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def pem @pem end |
Instance Method Details
#connect! ⇒ Object
10 11 12 13 14 15 |
# File 'lib/apnmachine/server/client.rb', line 10 def connect! raise "The path to your pem file is not set." unless @pem raise "The path to your pem file does not exist!" unless File.exist?(@pem) @key, @cert = @pem, @pem @connection = EM.connect(apn_host, apn_port, ApnMachine::Server::ServerConnection, self) end |
#connected? ⇒ Boolean
26 27 28 |
# File 'lib/apnmachine/server/client.rb', line 26 def connected? @connection.connected? end |
#disconnect! ⇒ Object
17 18 19 |
# File 'lib/apnmachine/server/client.rb', line 17 def disconnect! @connection.close_connection end |
#on_close(&block) ⇒ Object
34 35 36 |
# File 'lib/apnmachine/server/client.rb', line 34 def on_close(&block) @close_callback = block end |
#on_error(&block) ⇒ Object
30 31 32 |
# File 'lib/apnmachine/server/client.rb', line 30 def on_error(&block) @error_callback = block end |