Class: Rapns::Daemon::DeliveryHandler

Inherits:
Object
  • Object
show all
Includes:
Reflectable
Defined in:
lib/rapns/daemon/delivery_handler.rb

Direct Known Subclasses

Apns::DeliveryHandler, Gcm::DeliveryHandler

Constant Summary collapse

WAKEUP =
:wakeup

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reflectable

#reflect

Instance Attribute Details

#queueObject

Returns the value of attribute queue.



8
9
10
# File 'lib/rapns/daemon/delivery_handler.rb', line 8

def queue
  @queue
end

Instance Method Details

#startObject



10
11
12
13
14
15
16
17
# File 'lib/rapns/daemon/delivery_handler.rb', line 10

def start
  @thread = Thread.new do
    loop do
      handle_next_notification
      break if @stop
    end
  end
end

#stopObject



19
20
21
# File 'lib/rapns/daemon/delivery_handler.rb', line 19

def stop
  @stop = true
end

#waitObject



27
28
29
30
# File 'lib/rapns/daemon/delivery_handler.rb', line 27

def wait
  @thread.join if @thread
  stopped
end

#wakeupObject



23
24
25
# File 'lib/rapns/daemon/delivery_handler.rb', line 23

def wakeup
  queue.push(WAKEUP) if @thread
end