electric_slide - play before connecting calls

25 views
Skip to first unread message

tal weissler

unread,
May 9, 2017, 9:57:07 AM5/9/17
to Adhearsion
Hello, 
I'm using electric_slide to create a queue and I would like to play something to the person about to leave the queue before he is connected to an agent.

I found the method on_connect:
  • on_connect: Args: [Queue, Agent Call, Client Call] Called as the agent is being connected to the client call
which is defined in agent.rb:

def self.on_connect(&block)
@connect_callback = block
end

When I try to execute agent.class.on_connect {play "hello-world"} it crashes because <NoMethodError> undefined method `play' for #<ElectricSlide::Agent:0x00000003813488>
This happens because it's being implemented with instance_exec which takes the Agent's binding and not the lexical scope.

How can I play on the call received by the callback?


Thanks,
Tal



Giorgio Bianchi

unread,
May 11, 2017, 3:43:03 AM5/11/17
to Adhearsion
Hi, I think you should try something like this :

agent.class.on_connect do |queue,agent_call,client_call|
  client_call
.execute_controller do
    play
"hello-world"
 
end
end

I don't know if this code works but the key concept is : you should execute a controller over the affected call to make it do something.
Let me know if this helps!
Giorgio

tal weissler

unread,
May 15, 2017, 10:33:38 AM5/15/17
to Adhearsion
Hi,

Unfortunately, when I tried that it gave me this error:
<NoMethodError> undefined method `play' for #<Celluloid::ThreadHandle:0x000000049d6cd8>

However, I did manage to solve to problem this way:

1. In the class where I'm adding callers to the queue, I added:

    call[:controller] = self

2. Then in the class where I'm adding the agents:

    agent.class.on_connect do |queue, agent, client| 
      client[:controller].play "hello-world"
    end

that did the trick for me

Thanks,
Tal
Reply all
Reply to author
Forward
0 new messages