[Freeswitch-users] Loosing control when bridging calls using Lua

Michael Lutz mytemike72 at gmail.com
Thu Jan 19 16:56:15 MSK 2012


Hi All,

I am struggling with some code, I have (based on the wiki examples)
the following piece of lua code:

session:setHangupHook("HangUpDialAbort")
legA = session
legB = freeswitch.Session("sofia/external/{MYDESTINATION}@{MYEXTERNALGATEWAY}")
dispoB = "None"
while(legA:ready() and legB:ready() and dispoB ~= "ANSWER") do
   if ( not legA:ready() ) then
     freeswitch.consoleLog("NOTICE","It appears that leg_a
disconnected...\n")
   else
     dispoB = legB:getVariable("endpoint_disposition")
   end
 end

 if ( legA:ready() and legB:ready() ) then
	freeswitch.bridge(legA,legB)
	while(legA:ready() and legB:ready()) do
		freeswitch.consoleLog("NOTICE","We´re in the loop!\n")
	end
 else
	freeswitch.consoleLog("NOTICE","It appears that " .. dialA .. " or "
.. dialB .. " disconnected...\n")
 end

Question 1:
It seems freeswitch.bridge() is a blocking function, Is there a way to
use it in a non-blocking way? (so it will reach my while loop checking
for legA and B to be ready) I need control of my code while the two
legs are bridged.

Question 2: session:setHangupHook("HangUpDialAbort")
How can I pass session object to my hangup hook?  I need to abort the
dial attempt in my hangup hook when legA disconnects. Or are there
other (better) ways of doing this?

Question3: Is it possible to set different hangup hooks for different
session (legs)? (would need that when question 2 leads to a 'no-go'
...)



Thanks for your help,
Michael Lutz



Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list