<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
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:<br>
<br>
<tt><small>result = con.api('sched_api +8 none uuid_broadcast ' +
leg1_uuid + ' /var/www/mi/audio/ringback.mp3 aleg')<br>
result_body = result.getBody().to_s.gsub(/\n/,'') <br>
result_elements = result_body.scan(/(.+\:)\s+(\d+)/).collect {
|result_msg, id| { :result_msg => result_msg, :id => id }<br>
job_id = result_elements[0][:id] <br>
puts "job_id: #{job_id}" <br>
puts "uuid_setvar #{leg1_uuid} ringback_job_id #{job_id}"<br>
con.bgapi("uuid_setvar #{leg1_uuid} ringback_job_id #{job_id}")<br>
</small></tt><br>
Output:<br>
<br>
<small><tt>job_id: 46<br>
uuid_setvar 2e41916f-8f33-4c4e-9583-91b9953a61e1 ringback_job_id
46</tt></small><br>
<br>
Thanks anyway.<br>
<br>
Best,<br>
<br>
Claudio<br>
<br>
On 10/13/11 12:03 PM, Claudio Álvarez wrote:
<blockquote cite="mid:4E96FDA8.8@clickfono.com" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Hi all,<br>
<br>
I'm currently experimenting with sched_api to schedule a ringback
sound from a Ruby script. My code looks like this:<br>
<br>
<small><tt>ringback_result = con.bgapi('sched_api +8 none
uuid_broadcast ' + leg1_uuid + '
/var/www/mi/audio/ringback.mp3 aleg')<br>
puts "Serialized result:"<br>
puts ringback_result.serialize()</tt></small><br>
<br>
When I run the script, my output looks like:<br>
<br>
<small><tt>Serialized result:<br>
Event-Name: SOCKET_DATA<br>
Content-Type: command/reply<br>
Reply-Text:
%2BOK%20Job-UUID%3A%20cec047cc-97d7-4320-811a-e15e454843f9<br>
Job-UUID: cec047cc-97d7-4320-811a-e15e454843f9</tt><br>
</small><br>
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.<br>
<br>
<tt><small>sched_api +8 none uuid_broadcast
41b482a9-8595-47d4-a3fd-3c6a0d32e942
/var/www/mi/audio/ringback.mp3 aleg<br>
+OK Added: 34<br>
</small></tt><br>
Can anyone help me out with this one?<br>
<br>
Thanks!<br>
<pre class="moz-signature" cols="72">--
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
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:claudio@clickfono.com">claudio@clickfono.com</a></pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
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
<a class="moz-txt-link-abbreviated" href="mailto:claudio@clickfono.com">claudio@clickfono.com</a></pre>
</body>
</html>