Class: Pushr::Daemon::Apns2
- Inherits:
-
Object
- Object
- Pushr::Daemon::Apns2
- Defined in:
- lib/pushr/daemon/apns2.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#handlers ⇒ Object
Returns the value of attribute handlers.
Instance Method Summary collapse
-
#initialize(options) ⇒ Apns2
constructor
A new instance of Apns2.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Apns2
Returns a new instance of Apns2.
6 7 8 9 |
# File 'lib/pushr/daemon/apns2.rb', line 6 def initialize() @configuration = @handlers = [] end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/pushr/daemon/apns2.rb', line 4 def configuration @configuration end |
#handlers ⇒ Object
Returns the value of attribute handlers.
4 5 6 |
# File 'lib/pushr/daemon/apns2.rb', line 4 def handlers @handlers end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pushr/daemon/apns2.rb', line 11 def start configuration.connections.times do |i| connection = Apns2Support::Connection.new(configuration, i + 1) connection.connect # connection.on(:error) do |exception| # puts "Exception has been raised: #{exception}" # connection.connect # end handler = MessageHandler.new("pushr:#{configuration.key}", connection, configuration.app, i + 1) handler.start @handlers << handler end end |
#stop ⇒ Object
26 27 28 29 |
# File 'lib/pushr/daemon/apns2.rb', line 26 def stop @handlers.map(&:stop) @handlers.map { |handler| Thread.new { handler.connection.close } } end |