class ElectricSlide::Agent

Attributes

address[RW]
call[RW]
id[RW]
presence[R]
queue[RW]

Public Class Methods

new(opts = {}) click to toggle source

@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
on_connect(&block) click to toggle source

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
on_connection_failed(&block) click to toggle source

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
on_disconnect(&block) click to toggle source

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
on_presence_change(&block) click to toggle source

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

callback(type, *args) click to toggle source
# 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
dial_options_for(queue, queued_call) click to toggle source

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
from() click to toggle source

FIXME: Use delegator?

# File lib/electric_slide/agent.rb, line 68
def from
  @call.from
end
join(queued_call) click to toggle source
# 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
on_call?() click to toggle source
# File lib/electric_slide/agent.rb, line 53
def on_call?
  @presence == :on_call
end
update_presence(new_presence, extra_params = {}) click to toggle source
# 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