[Freeswitch-users] ESL Ruby - sched_api / task id issue
Claudio Álvarez
claudio at clickfono.com
Thu Oct 13 20:13:34 MSD 2011
Hi all,
I finally nailed it. I was calling bgapi (api call in the background),
whereas I should have just called the synchronous 'api' method. The
synchronous api call returns the scheduled task inmediatly:
result = con.api('sched_api +8 none uuid_broadcast ' + leg1_uuid + '
/var/www/mi/audio/ringback.mp3 aleg')
result_body = result.getBody().to_s.gsub(/\n/,'')
result_elements = result_body.scan(/(.+\:)\s+(\d+)/).collect {
|result_msg, id| { :result_msg => result_msg, :id => id }
job_id = result_elements[0][:id]
puts "job_id: #{job_id}"
puts "uuid_setvar #{leg1_uuid} ringback_job_id #{job_id}"
con.bgapi("uuid_setvar #{leg1_uuid} ringback_job_id #{job_id}")
Output:
job_id: 46
uuid_setvar 2e41916f-8f33-4c4e-9583-91b9953a61e1 ringback_job_id 46
Thanks anyway.
Best,
Claudio
On 10/13/11 12:03 PM, Claudio Álvarez wrote:
> Hi all,
>
> I'm currently experimenting with sched_api to schedule a ringback
> sound from a Ruby script. My code looks like this:
>
> ringback_result = con.bgapi('sched_api +8 none uuid_broadcast ' +
> leg1_uuid + ' /var/www/mi/audio/ringback.mp3 aleg')
> puts "Serialized result:"
> puts ringback_result.serialize()
>
> When I run the script, my output looks like:
>
> Serialized result:
> Event-Name: SOCKET_DATA
> Content-Type: command/reply
> Reply-Text: %2BOK%20Job-UUID%3A%20cec047cc-97d7-4320-811a-e15e454843f9
> Job-UUID: cec047cc-97d7-4320-811a-e15e454843f9
>
> The problem here is that I'm not getting the scheduled task ID
> returned by sched_api I expect. I need the task ID so as to run
> sched_del should I need to abort the task. Trying the same api_sched
> command on fs_cli I get an output confirming that the task has been
> added, together with the assigned task ID.
>
> sched_api +8 none uuid_broadcast 41b482a9-8595-47d4-a3fd-3c6a0d32e942
> /var/www/mi/audio/ringback.mp3 aleg
> +OK Added: 34
>
> Can anyone help me out with this one?
>
> Thanks!
> --
> Claudio Álvarez, Ph.D.
> Arquitecto de Sistemas / Systems Architect
> Medularis S.p.A. - ClickFono
> Tel: 56 2 934 40 74
> Cel: 56 9 9079 4951
> claudio at clickfono.com
--
Claudio Álvarez, Ph.D.
Arquitecto de Sistemas / Systems Architect
Medularis S.p.A. - ClickFono
Tel: 56 2 934 40 74
Cel: 56 9 9079 4951
claudio at clickfono.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111013/b62a0fb4/attachment-0001.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list