In my application, I seldom route calls. The task is to use FS as a automated business coordinator over phone. Users call the system to update their information and raise requests. The system collect these information and upload to database. With real-time data, FS make decision and give out instruction through SMS or out-going calls.<div>
In this interesting situation, Freeswitch become Never-Switch, because it takes the responsibility itself to communicate with each caller/callee instead of switching to others.</div><div>That's why my script become complex.<br>
<br><div class="gmail_quote">On Sat, Jul 24, 2010 at 8:03 AM, Sergey Okhapkin <span dir="ltr"><<a href="mailto:sos@sokhapkin.dyndns.org">sos@sokhapkin.dyndns.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Which task do you want to accomplish? To me dynamic generation of FS dialplan<br>
from a script (language doesn't matter) works better than realtime call flow<br>
control from a script, event socket etc. I do call routing, no PBX functions.<br>
<div><div></div><div class="h5"><br>
On Friday 23 July 2010, xuyan yang wrote:<br>
> I know the solution of putting "if(!session.ready())exit()" to every check<br>
> point. But as my script already has nearly 3000 lines, there are too<br>
> many "if(!session.ready())exit()" to add.<br>
><br>
> I tried error(); it works just because error is not defined. Using<br>
> intentional mistake to force exit is creative but strange.<br>
> After some thoughts I found that throw a user defined exception in the hook<br>
> may be a better way to force exit without the red [ERR] line.<br>
><br>
> By the way, I still feel that let exit() in the hook stop the whole script<br>
> instead of the hook only seems to be more consistent because they are<br>
> not executed in separate thread. Would you please consider this if it is<br>
> not difficult? Thanks.<br>
><br>
><br>
> On Sat, Jul 24, 2010 at 6:17 AM, Anthony Minessale <<br>
><br>
> <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>> wrote:<br>
> > if session.ready is false it means the channel is hungup.<br>
> ><br>
> > error(); will exit your script.<br>
> ><br>
> > you can probably remove some of them if you are getting better results<br>
> > with the patch.<br>
> ><br>
> > On Fri, Jul 23, 2010 at 4:56 PM, xuyan yang <<a href="mailto:xyangni@gmail.com">xyangni@gmail.com</a>> wrote:<br>
> >> Thanks for your update. I have tested it again base on the latest git<br>
> >> tree, the hangup hook does work every time and the script continue to<br>
> >> run without error message.<br>
> >><br>
> >> But this behaviour change caused another problem as I still need to stop<br>
> >> the script when the session is hangup.<br>
> >> Adding if(session.ready()) to every line of my script does not seem to<br>
> >> be a good solution. So I decided to call exit() in the hangup hook.<br>
> >> However the test result is that exit() in hangup hook only works the<br>
> >> same as "return". That means exit() in hangup hook only stops the hook<br>
> >> while the main program can not be stopped.<br>
> >><br>
> >> Is there any good solution to stop the script immediately when hangup?<br>
> >><br>
> >> On Sat, Jul 24, 2010 at 3:13 AM, Anthony Minessale <<br>
> >><br>
> >> <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>> wrote:<br>
> >>> give lastest HEAD a try, I pushed in some more checks and made calling<br>
> >>> session.hangup() nonfatal when it's already hungup.<br>
> >>><br>
> >>> On Fri, Jul 23, 2010 at 1:27 PM, xuyan yang <<a href="mailto:xyangni@gmail.com">xyangni@gmail.com</a>> wrote:<br>
> >>>> I added many session.ready() as below and re-do the test again.<br>
> >>>> the steps are:<br>
> >>>> 1. type jsrun test.js in fs_cli<br>
> >>>> 2. answer the call in x-lite.<br>
> >>>> 3. when I hear the speech, hangup the call in about 1 second.<br>
> >>>> 4 check the log to find "hangup!!!!!!!!!!!!!"<br>
> >>>><br>
> >>>> the result is that<br>
> >>>> about half of the test failed to call hangup hook.<br>
> >>>> in all tests the script end up with [ERR] inline:1 Session is not<br>
> >>>> active! then the script stopped and session.ready() near the end<br>
> >>>> can not get the chance to run.<br>
> >>>><br>
> >>>><br>
> >>>><br>
> >>>> ////test.js<br>
> >>>> function on_hangup(session, how){<br>
> >>>> console_log("notice","hangup!!!!!!!!!!!!!\n");<br>
> >>>> }<br>
> >>>><br>
> >>>> session = new Session("sofia/gateway/12voip-out/*********");<br>
> >>>> session.waitForAnswer();<br>
> >>>> session.ready();<br>
> >>>> session.execute("set","continue_on_fail=true");<br>
> >>>> var res=session.setHangupHook(on_hangup);<br>
> >>>> console_log("notice","res:"+res+"\n");<br>
> >>>> if(session.ready())session.execute("speak", "This is an example of<br>
> >>>> flite text to speech engine. We can test the work of hanguphook.");<br>
> >>>> if(session.ready())session.execute("speak","you are calling from " +<br>
> >>>> session.caller_id_num + " You are calling " + session.destination );<br>
> >>>> session.ready();<br>
> >>>> session.hangup();<br>
> >>>><br>
> >>>> On Sat, Jul 24, 2010 at 1:08 AM, Anthony Minessale <<br>
> >>>><br>
> >>>> <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>> wrote:<br>
> >>>>> It checks before and after blocking calls like that.<br>
> >>>>><br>
> >>>>> On Jul 23, 2010 11:53 AM, "Dan" <<a href="mailto:freeswitch-users@digitaldan.com">freeswitch-users@digitaldan.com</a>><br>
> >>>>> wrote:<br>
> >>>>><br>
> >>>>> So If I call session.recordFile which blocks in code until the user<br>
> >>>>> hangs up, and can't make periodic calls to session.ready, is the<br>
> >>>>> hangup hook not realiable in this scenario?<br>
> >>>>><br>
> >>>>> ------------------------------<br>
> >>>>> *From: *"Anthony Minessale" <<a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>><br>
> >>>>> *To: *"FreeSWITCH Users Help" <<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>><br>
> >>>>> *Sent: *Thursday, July 22, 2010 10:30:48 AM<br>
> >>>>> *Subject: *Re: [Freeswitch-users] Unstable hangup hook in javascript<br>
> >>>>><br>
> >>>>><br>
> >>>>><br>
> >>>>> You must make periodic calls to session.ready() or some other<br>
> >>>>> freeswitch api functions to trigger ...<br>
> >>>>><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:<br>
> >>>>> <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>
> >>>>> _______________________________________________<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:<br>
> >>>>> <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>
> >>>> 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:<br>
> >>>> <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>
> >>> Anthony Minessale II<br>
> >>><br>
> >>> FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>
> >>> ClueCon <a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br>
> >>> Twitter: <a href="http://twitter.com/FreeSWITCH_wire" target="_blank">http://twitter.com/FreeSWITCH_wire</a><br>
> >>><br>
> >>> AIM: anthm<br>
</div></div>> >>> <a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a> <<a href="mailto:MSN%253Aanthony_minessale@hotmail.com">MSN%3Aanthony_minessale@hotmail.com</a>><br>
> >>> GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><PAYPAL%3Aanthony.miness<br>
<div class="im">> >>><a href="mailto:ale@gmail.com">ale@gmail.com</a>> IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br>
> >>><br>
> >>> FreeSWITCH Developer Conference<br>
</div>> >>> <a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a> <<a href="mailto:sip%253A888@conference.freeswitch.org">sip%3A888@conference.freeswitch.org</a>><br>
> >>> <a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><googletalk%3Aconf%2B888@c<br>
<div class="im">> >>><a href="http://onference.freeswitch.org" target="_blank">onference.freeswitch.org</a>> pstn:+19193869900<br>
> >>><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-user" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-user</a><br>
</div>> >>>s <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<div class="im">> >><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>
> > --<br>
> > Anthony Minessale II<br>
> ><br>
> > FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>
> > ClueCon <a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br>
> > Twitter: <a href="http://twitter.com/FreeSWITCH_wire" target="_blank">http://twitter.com/FreeSWITCH_wire</a><br>
> ><br>
> > AIM: anthm<br>
</div>> > <a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a> <<a href="mailto:MSN%253Aanthony_minessale@hotmail.com">MSN%3Aanthony_minessale@hotmail.com</a>><br>
> > GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><PAYPAL%3Aanthony.minessal<br>
<div class="im">> ><a href="mailto:e@gmail.com">e@gmail.com</a>> IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br>
> ><br>
> > FreeSWITCH Developer Conference<br>
</div>> > <a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a> <<a href="mailto:sip%253A888@conference.freeswitch.org">sip%3A888@conference.freeswitch.org</a>><br>
> > <a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><googletalk%3Aconf%2B888@con<br>
<div><div></div><div class="h5">> ><a href="http://ference.freeswitch.org" target="_blank">ference.freeswitch.org</a>> pstn:+19193869900<br>
> ><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>
<br>
<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>
</div></div></blockquote></div><br></div>