Sha256: eb159e80cf41d4ce7717e036c3085176819891d01c99be3ec84bc94d203d0ab0

Contents?: true

Size: 1.4 KB

Versions: 13

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

# :reek:UtilityFunction

module RubyRabbitmqJanus
  module Process
    module Concurrencies
      # Manage message used for keepalive thread
      #
      # @attribute [r] instance
      #   @return [String] ID to Janus Instance
      class KeepaliveMessage
        attr_reader :instance

        def initialize(instance)
          @instance = instance.id
        end

        def session
          Janus::Messages::Standard.new('base::create', param_instance)
        end

        def response_session(message)
          RubyRabbitmqJanus::Janus::Responses::Standard.new(message).session
        end

        def keepalive(session)
          parameter = param_session(session)
          Janus::Messages::Standard.new('base::keepalive', parameter)
        end

        def response_acknowledgement(message)
          RubyRabbitmqJanus::Janus::Responses::Standard.new(message).error?
        end

        def destroy(session)
          parameter = param_session(session)
          Janus::Messages::Standard.new('base::destroy', parameter)
        end

        def response_destroy(message)
          RubyRabbitmqJanus::Janus::Responses::Standard.new(message)
        end

        private

        def param_instance
          { 'instance' => @instance }
        end

        def param_session(session)
          { 'session_id' => session }.merge(param_instance)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.7.2.pre.312 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.310 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.309 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.308 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.307 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.306 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.305 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.302 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.297 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.296 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.286 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.285 lib/rrj/process/keepalive/keepalive_message.rb
ruby_rabbitmq_janus-2.7.2.pre.284 lib/rrj/process/keepalive/keepalive_message.rb