Sha256: 5c9f259c3600677563e8deb48443dc696c0bc2a3d7cac6d72d77bca5e0199045

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

module Adhearsion
  module VoIP
    module Asterisk
      module Manager


        ##
        # This is the object containing a response from Asterisk.
        #
        # Note: not all responses have an ActionID!
        #
        class ManagerInterfaceResponse

          class << self
            def from_immediate_response(text)
              new.tap do |instance|
                instance.text_body = text
              end
            end
          end

          attr_accessor :action,
                        :action_id,
                        :text_body  # For "Response: Follows" sections
          attr_reader   :events

          def initialize
            @headers = HashWithIndifferentAccess.new
          end

          def has_text_body?
            !! @text_body
          end

          def headers
            @headers.clone
          end

          def [](arg)
            @headers[arg]
          end

          def []=(key,value)
            @headers[key] = value
          end

        end

        class ManagerInterfaceError < StandardError

          attr_accessor :message
          def initialize
            @headers = HashWithIndifferentAccess.new
          end

          def [](key)
            @headers[key]
          end

          def []=(key,value)
            @headers[key] = value
          end

        end

        class ManagerInterfaceEvent < ManagerInterfaceResponse

          attr_reader :name
          def initialize(name)
            super()
            @name = name
          end

        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
adhearsion-1.2.6 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.2.5 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.2.4 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.2.3 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.2.1 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.2.0 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.1.1 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.1.0 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.0.3 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.0.2 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-cw-1.0.2.3 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-cw-1.0.2.2 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-cw-1.0.2.1 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.0.1 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
adhearsion-1.0.0 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
rene-adhearsion-0.8.6 lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb