Well, I didn't say you *couldn't* do it, just that it isn't the best option. For posterity's sake here is a sample of a Lua script that does basically what you want. <div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">-- </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">-- cc.lua </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">-- </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">-- call control lua script - can it be done? </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">-- </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">dialA = "sofia/gateway/fs1/9903" </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">dialB = "user/1001" </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">legA = freeswitch.Session(dialA) </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">dispoA = "None" </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">while(legA:ready() and dispoA ~= "ANSWER") do </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> dispoA = legA:getVariable("endpoint_disposition") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> freeswitch.consoleLog("INFO","Leg A disposition is '" .. dispoA .. "'\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> os.execute("sleep 1") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">end -- legA while </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">if( not legA:ready() ) then </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> -- oops, lost leg A handle this case </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> freeswitch.consoleLog("NOTICE","It appears that " .. dialA .. " disconnected...\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">else </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> legB = freeswitch.Session(dialB) </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> dispoB = "None" </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> while(legA:ready() and legB:ready() and dispoB ~= "ANSWER") do </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> if ( not legA:ready() ) then </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> -- oops, leg A hung up or got disconnected, handle this case </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> freeswitch.consoleLog("NOTICE","It appears that " .. dialA .. " disconnected...\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> else </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> os.execute("sleep 1") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> dispoB = legB:getVariable("endpoint_disposition") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> freeswitch.consoleLog("NOTICE","Leg B disposition is '" .. dispoB .. "'\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> end -- inner if legA ready </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> end -- legB while </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> if ( legA:ready() and legB:ready() ) then </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> freeswitch.bridge(legA,legB) </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> else </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> -- oops, one of the above legs hung up, handle this case </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> freeswitch.consoleLog("NOTICE","It appears that " .. dialA .. " or " .. dialB .. " disconnected...\n") </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> end </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">end -- outter if legA ready </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div><div><br></div><div>-MC</div><br><div class="gmail_quote">On Tue, Sep 13, 2011 at 2:52 PM, Chrisbware <span dir="ltr"><<a href="mailto:chrisbware@interfree.it">chrisbware@interfree.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><u></u>
<div text="#000000" bgcolor="#ffffff">
Thank you for your answer: I'll follow your advice.<br>
<br>
Anyway, IMHO, Lua must be able to manage situations like this.
Languages strong integration is a plus<br>
of FS that helps programmers to invent new services. Telling them
they still have to play with events<br>
sounds a bit "old school". Again: it's only my opinon. Keep up the
good work!<br>
<br>
Il 13/09/2011 23:27, Michael Collins ha scritto:
<div><div></div><div class="h5"><blockquote type="cite">
<div>Chris,</div>
<div><br>
</div>
<div>We're glad you like FS - we like it as well.</div>
<div><br>
</div>
What you're trying to do is completely possible, but the way
you're trying to do it is probably not the best choice. Instead of
a local Lua script to control both calls, you are better off using
either one of two options: event socket entirely or event socket +
dialplan. It depends on the level of control that you need. If you
want ultimate control then just use ESL right from PHP (or
whichever scripting language you are comfortable with) and create
your call legs, watching for the requisite CHANNEL_XXX events.
(See <a href="http://wiki.freeswitch.org/wiki/Event_List" target="_blank">http://wiki.freeswitch.org/wiki/Event_List</a>
for a nice list.)
<div>
<br>
</div>
<div>I suppose you could do it all in Lua but you'd have to keep
polling legA channel for the endpoint_disposition variable in a
while loop and then break out on various conditions. I'm not at
all a fan of that method. With the event socket you listen for
the events that are of interest to you and then act on them.
Very elegant.</div>
<div><br>
</div>
<div>-MC<br>
<br>
<div class="gmail_quote">On Tue, Sep 13, 2011 at 1:59 PM,
Chrisbware <span dir="ltr"><<a href="mailto:chrisbware@interfree.it" target="_blank">chrisbware@interfree.it</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div text="#000000" bgcolor="#ffffff"> Hi Michael,<br>
<br>
a PHP script connect to Event socket and launch "luarun
call.lua <legA number> <legB number> <sip
account number><br>
<br>
Script call.lua, upload sip account password from a DB and
then call A number and B number using the same SIP
account, bridging them.<br>
What I'd like to do is:<br>
<br>
- place call to legB number only after legA has answered
the call<br>
- detect hangupCause on both legs to check if something
goes wrong<br>
- return SUCCESS or hangup cause to the PHP script <br>
<br>
Is it science fiction? With Asterisk isn't so hard to do
and, since I'm in love with FS, please don't disappoint me
:-)<br>
<br>
Chris B.<br>
<br>
<br>
Il 13/09/2011 18:44, Michael Collins ha scritto:
<div>
<div>
<blockquote type="cite">How are you calling this Lua
script to begin with? What is the big picture, that
is, what is the problem you're solving? Some context
might help us give you a better answer.
<div><br>
</div>
<div>-MC<br>
<br>
<div class="gmail_quote"> On Tue, Sep 13, 2011 at
5:21 AM, <span dir="ltr"><<a href="mailto:chrisbware@interfree.it" target="_blank">chrisbware@interfree.it</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"> <span>Hi,</span><br>
<span> </span><br>
<span>thank you for your help, but doesn't
work.</span><br>
<span>legA:ready() is true when the first
session start and not when the call is
answered.</span><br>
<span>So legB is called at the same time.</span><br>
<span> </span><br>
<span>Any other suggestion?</span><br>
<span> </span><br>
<span> </span><br>
<span> </span><br>
<span> </span><br>
<span>-----Messaggio originale-----</span><br>
<span>Da: Sergey Scheglov <<a href="mailto:sid@eltc.ru" target="_blank">sid@eltc.ru</a>></span><br>
<span>Inviato il: 13 Set 2011 - 17:15</span><br>
<span>A: <a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a></span>
<div>
<div><br>
<span><br>
<br>
? 13 Sep 2011 09:39:33 -0000<br>
<a href="mailto:chrisbware@interfree.it" target="_blank">chrisbware@interfree.it</a>
wrote:<br>
<br>
> <br>
> Hi guys,<br>
> <br>
> I've read anything on this argument
on Wiki but I can't find a<br>
> complete answer.<br>
> <br>
> I need to bridge two calls in Lua,
waiting the first to be answered.<br>
> My basic script is:<br>
> <br>
> local GwParams =<br>
>
"origination_caller_id_number="..gateway..",sip_auth_username="..gateway..",sip_auth_password="..sip_passwd<br>
> local slegA =<br>
>
"[ignore_early_media=false,"..GwParams.."]sofia/external/"..callee.."@"..sip_domain<br>
> local slegB =<br>
>
"[ignore_early_media=true,"..GwParams.."]sofia/external/"..called.."@"..sip_domain<br>
> <br>
> legA = freeswitch.Session(slegA);<br>
> legB = freeswitch.Session(slegB);<br>
> freeswitch.bridge(legA, legB);<br>
> <br>
> <br>
> It works but legA and legB are
called at the same time. Using:<br>
> <br>
> while (legA:answered()== false) do
end;<br>
> <br>
> between the two session do the job
but called parties can't hear<br>
> audio.<br>
> <br>
> I promise to add a script on wiki
if you help me ! :)<br>
> <br>
> Thanks in advance.<br>
> <br>
> <br>
>
-------------------------------------------------------------------------------<br>
> Valore legale alle tue mail<br>
> InterfreePEC - la tua Posta
Elettronica Certificata<br>
> <a href="http://pec.interfree.it" target="_blank">http://pec.interfree.it</a><br>
>
-------------------------------------------------------------------------------<br>
> <br>
> <br>
> <br>
> FreeSWITCH-users mailing list<br>
> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
> <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
> <br>
<br>
Try:<br>
<br>
legA = freeswitch.Session(slegA);<br>
if (legA:ready()) then<br>
legB = freeswitch.Session(slegB, legA);<br>
freeswitch.bridge(legA, legB);<br>
end<br>
<br>
----<br>
<br>
Scheglov Sergey<br>
<br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></span><br>
<br>
-------------------------------------------------------------------------------<br>
Valore legale alle tue mail<br>
InterfreePEC - la tua Posta Elettronica
Certificata<br>
<a href="http://pec.interfree.it" target="_blank">http://pec.interfree.it</a><br>
-------------------------------------------------------------------------------<br>
</div>
</div>
<br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<pre><fieldset></fieldset>
FreeSWITCH-users mailing list
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
<br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<pre><fieldset></fieldset>
FreeSWITCH-users mailing list
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
</pre>
</blockquote>
<br>
</div></div></div>
<br><br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>