Class: APND::Daemon
- Inherits:
-
Object
- Object
- APND::Daemon
- Defined in:
- lib/apnd/daemon.rb
Overview
The APND::Daemon maintains a persistent secure connection with Apple, (APND::Daemon::AppleConnection). Notifications are queued and periodically writen to the AppleConnection
Defined Under Namespace
Modules: Protocol Classes: AppleConnection, ServerConnection
Class Method Summary collapse
-
.run! ⇒ Object
Create a new Daemon and run it.
Instance Method Summary collapse
-
#initialize ⇒ Daemon
constructor
Create a connection to Apple and a new EM queue.
-
#run! ⇒ Object
Run the daemon.
Constructor Details
#initialize ⇒ Daemon
Create a connection to Apple and a new EM queue
25 26 27 28 29 30 31 |
# File 'lib/apnd/daemon.rb', line 25 def initialize @queue = EM::Queue.new @apple = APND::Daemon::AppleConnection.new @bind = APND.settings.daemon.bind @port = APND.settings.daemon.port @timer = APND.settings.daemon.timer end |
Class Method Details
Instance Method Details
#run! ⇒ Object
Run the daemon
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/apnd/daemon.rb', line 36 def run! EventMachine::run do APND.logger "Starting APND Daemon v#{APND::Version} on #{@bind}:#{@port}" EventMachine::start_server(@bind, @port, APND::Daemon::ServerConnection) do |server| server.queue = @queue end EventMachine::PeriodicTimer.new(@timer) do process_notifications! end end end |