class Pushr::Daemon::Apns2
Attributes
configuration[RW]
handlers[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/pushr/daemon/apns2.rb, line 6 def initialize(options) @configuration = options @handlers = [] end
Public Instance Methods
start()
click to toggle source
# 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()
click to toggle source
# File lib/pushr/daemon/apns2.rb, line 26 def stop @handlers.map(&:stop) @handlers.map { |handler| Thread.new { handler.connection.close } } end