Class: ApnMachine::Server::Client
- Inherits:
-
Object
- Object
- ApnMachine::Server::Client
- Defined in:
- lib/apnmachine/server/client.rb
Instance Attribute Summary collapse
-
#cert ⇒ Object
Returns the value of attribute cert.
-
#close_callback ⇒ Object
Returns the value of attribute close_callback.
-
#host ⇒ Object
Returns the value of attribute host.
-
#key ⇒ Object
Returns the value of attribute key.
-
#password ⇒ Object
Returns the value of attribute password.
-
#pem ⇒ Object
Returns the value of attribute pem.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #connect! ⇒ Object
- #connected? ⇒ Boolean
- #disconnect! ⇒ Object
-
#initialize(pem, host = 'gateway.push.apple.com', port = 2195, pass = nil) ⇒ Client
constructor
A new instance of Client.
- #on_close(&block) ⇒ Object
- #on_error(&block) ⇒ Object
- #write(notif_bin) ⇒ Object
Constructor Details
#initialize(pem, host = 'gateway.push.apple.com', port = 2195, pass = nil) ⇒ Client
Returns a new instance of Client.
6 7 8 |
# File 'lib/apnmachine/server/client.rb', line 6 def initialize(pem, host = 'gateway.push.apple.com', port = 2195, pass = nil) @pem, @host, @port, @password = pem, host, port, pass end |
Instance Attribute Details
#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 |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def host @host 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 |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/apnmachine/server/client.rb', line 4 def port @port 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(host, 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 |