class Receiver
Public Class Methods
new(config)
click to toggle source
# File lib/test_driven_lighting/receiver.rb, line 7 def initialize(config) @connection = Bunny.new("amqp://#{config[:bunny_username]}:#{config[:bunny_password]}@#{config[:bunny_host]}").start @channel = @connection.create_channel @exchange = @channel.fanout('lighting.messages') end
Public Instance Methods
listen(queue_name) { |parse| ... }
click to toggle source
# File lib/test_driven_lighting/receiver.rb, line 13 def listen(queue_name, &block) puts 'listening for light messages...' @channel.queue(queue_name, :auto_delete => true).bind(@exchange).subscribe(:block => true) do |delivery_info, metadata, payload| yield JSON.parse(payload) end end