Sha256: df40bd74aa305a60cb9878c0d27345af8fb581a143a2cccff3b525c0383b771f

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Rabbit
    module Listener
      # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
      #
      # This publisher don't post message. Is listen just an admin queue to
      # Janus. By default is "from-janus-admin". It's a parameter in config
      # to this gem.
      class FromAdmin < From
        private

        def reply
          rabbit.queue(Tools::Config.instance.queue_admin_from)
        end

        def subscribe_queue
          rabbit.prefetch(1)
          reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
            info_subscribe(info, prop, payload)
            synchronize_response(info, payload)
          end
        rescue => exception
          raise RubyRabbitmqJanus::Errors::Rabbit::Listener::From::ListenEvents,
                exception
        end

        def synchronize_response(info, payload)
          lock.synchronize do
            response = Janus::Responses::Admin.new(JSON.parse(payload))
            responses.push(response)
          end
          rabbit.acknowledge(info.delivery_tag, false)
          semaphore.signal
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-3.0.0.pre.336 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-3.0.0.pre.335 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-3.0.0.pre.334 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-3.0.0.pre.330 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-3.0.0.pre.328 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-3.0.0.pre.327 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-2.7.2 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-2.7.2.pre.322 lib/rrj/rabbit/listener/from_admin.rb
ruby_rabbitmq_janus-2.7.2.pre.320 lib/rrj/rabbit/listener/from_admin.rb