Sha256: 22bb3185fe9b1161523585b0fc0874e0b860927501a59c1e01f768fb695633d4
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# encoding: utf-8 class ElectricSlide::Agent attr_accessor :id, :address, :presence, :call, :connect_callback, :disconnect_callback # @param [Hash] opts Agent parameters # @option opts [String] :id The Agent's ID # @option opts [String] :address The Agent's contact address # @option opts [Symbol] :presence The Agent's current presence. Must be one of :available, :on_call, :away, :offline def initialize(opts = {}) @id = opts[:id] @address = opts[:address] @presence = opts[:presence] end def callback(type, *args) callback = self.class.instance_variable_get "@#{type}_callback" instance_exec *args, &callback if callback && callback.respond_to?(:call) end # Provide a block to be called when this agent is connected to a caller # The block will be passed the queue, the agent call and the client call def self.on_connect(&block) @connect_callback = block end # Provide a block to be called when this agent is disconnected to a caller # The block will be passed the queue, the agent call and the client call def self.on_disconnect(&block) @disconnect_callback = block end # Called to provide options for calling this agent that are passed to #dial def dial_options_for(queue, queued_call) {} end def join(queued_call) # For use in queues that need bridge connections @call.join queued_call end # FIXME: Use delegator? def from @call.from end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
electric_slide-0.2.0 | lib/electric_slide/agent.rb |