class ElectricSlide::Agent
Attributes
Public Class Methods
@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, :after_call, :unavailable
# File lib/electric_slide/agent.rb, line 12 def initialize(opts = {}) @id = opts[:id] @address = opts[:address] @presence = opts[:presence] || :available 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
# File lib/electric_slide/agent.rb, line 31 def self.on_connect(&block) @connect_callback = block end
Provide a block to be called when the agent connection to the callee fails The block will be passed the queue, the agent call and the client call
# File lib/electric_slide/agent.rb, line 49 def self.on_connection_failed(&block) @connection_failed_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
# File lib/electric_slide/agent.rb, line 37 def self.on_disconnect(&block) @disconnect_callback = block end
Provide a block to be called when this agent’s presence changes The block will be passed the queue, the agent call, and the new presence
# File lib/electric_slide/agent.rb, line 43 def self.on_presence_change(&block) @presence_change_callback = block end
Public Instance Methods
# File lib/electric_slide/agent.rb, line 24 def callback(type, *args) callback = self.class.instance_variable_get "@#{type}_callback" instance_exec *args, &callback if callback && callback.respond_to?(:call) end
Called to provide options for calling this agent that are passed to dial
# File lib/electric_slide/agent.rb, line 58 def dial_options_for(queue, queued_call) {} end
FIXME: Use delegator?
# File lib/electric_slide/agent.rb, line 68 def from @call.from end
# File lib/electric_slide/agent.rb, line 62 def join(queued_call) # For use in queues that need bridge connections @call.join queued_call end
# File lib/electric_slide/agent.rb, line 53 def on_call? @presence == :on_call end
# File lib/electric_slide/agent.rb, line 18 def update_presence(new_presence, extra_params = {}) old_presence = @presence @presence = new_presence callback :presence_change, queue, @call, new_presence, old_presence, extra_params end