Class: AppleShove::Demultiplexer
- Inherits:
-
Object
- Object
- AppleShove::Demultiplexer
- Defined in:
- lib/apple_shove/demultiplexer.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Demultiplexer
constructor
A new instance of Demultiplexer.
- #start ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Demultiplexer
Returns a new instance of Demultiplexer.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/apple_shove/demultiplexer.rb', line 4 def initialize(opts = {}) unless opts[:max_apns_connections] raise ArgumentError, 'max_apns_connections must be specified' end @max_connections = opts[:max_apns_connections].to_i @connections = {} @queue = NotificationQueue.new(CONFIG[:redis_key]) end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/apple_shove/demultiplexer.rb', line 15 def start while true if notification = @queue.get conn = get_connection(notification) conn.pending_notifications += 1 conn.async.send(notification) else sleep 1 end end end |