Sha256: e79b99f1a21bd42ef86ff9d7fd7ca7afec286802e7187c8a22041fd95f36a03b

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

module Punchblock
  module Translator
    class Asterisk
      module Component
        extend ActiveSupport::Autoload

        autoload :Asterisk

        class Component
          include Celluloid

          attr_reader :id, :call

          def initialize(component_node, call = nil)
            @component_node, @call = component_node, call
            @id = UUIDTools::UUID.random_create.to_s
            setup
            pb_logger.debug "Starting up..."
          end

          def setup
          end

          def set_node_response(value)
            pb_logger.debug "Setting response on component node to #{value}"
            @component_node.response = value
          end

          def send_ref
            set_node_response Ref.new :id => id
          end

          def with_error(name, text)
            set_node_response ProtocolError.new(name, text)
          end

          def complete_event(reason)
            Punchblock::Event::Complete.new.tap do |c|
              c.reason = reason
            end
          end

          def send_event(event)
            event.component_id = id
            pb_logger.debug "Sending event #{event}"
            @component_node.add_event event
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
punchblock-0.8.2 lib/punchblock/translator/asterisk/component.rb
punchblock-0.8.1 lib/punchblock/translator/asterisk/component.rb