<br>What do you suggest is not working?<br><br>the call failed and it *did not* run the code inside if (new_session.ready())<br>The call was never established therefore it would not run the hangup hook either.<br>In order to trigger the hangup hook the session would need to exist. If the session could not originate the new_session obj<br>
is an empty shell with no actual session inside.<br><br>var new_session = new Session(<dial string>, <existing session>);<br>if (!new_session.ready()) {<br> // the call never was established.<br>}<br><br>I gave you real code to try in my last email that you completely ignored.....<br>
<br><br>and finally you are declaring the function wrong<br><br>declare it at the top.<br><br>function on_hangup(hup_session, how)<br>{<br>.....<br>}<br><br>I sense you seem to think things are going to magically transform into however you are thinking they should work<br>
instead of you perhaps learning how they actually work.<br><br><br><br><div class="gmail_quote">On Sat, Feb 14, 2009 at 1:47 PM, Nik Middleton <span dir="ltr"><<a href="mailto:nik.middleton@noblesolutions.co.uk">nik.middleton@noblesolutions.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="blue" lang="EN-US">
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Nope,</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Still not working. Here's my little
test javascript</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">var new_session = new
Session('{ignore_early_media=true,}sofia/internal/<a href="mailto:1001@192.168.3.206" target="_blank">1001@192.168.3.206</a>');</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> //set the on_hangup function
to be called when this session is hungup </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> new_session.setHangupHook(on_hangup,"hup");
</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> var on_hangup =
function(hup_session, how)
{
</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> console_log("err","In
hangup section\n"); </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> //exit
here would end the script so you could cleanup and just be
done
</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> exit();
</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> } </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> if (new_session.ready()) {</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> new_session.answer(
);</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> new_session.sleep(1500);</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> new_session.streamFile("female2.wav");</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> }</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">And this is the output</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">[NOTICE] sofia.c:3090
sofia_handle_sip_i_state() Hangup sofia/internal/<a href="http://sip:1001@192.168.0.29:5060" target="_blank">sip:1001@192.168.0.29:5060</a>
[CS_CONSUME_MEDIA] [USER_BUSY]</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">[ERR] switch_ivr_originate.c:1116
switch_ivr_originate() Cannot create outgoing channel of type [user] cause:
[USER_BUSY]</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">[INFO] mod_dptools.c:1909
audio_bridge_function() Originate Failed. Cause: USER_BUSY</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">[NOTICE] switch_core_session.c:957
switch_core_session_thread() Session 95
(sofia/internal/<a href="http://sip:1001@192.168.0.29:5060" target="_blank">sip:1001@192.168.0.29:5060</a>) Ended</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">[NOTICE] switch_core_session.c:959
switch_core_session_thread() Close Channel sofia/internal/<a href="http://sip:1001@192.168.0.29:5060" target="_blank">sip:1001@192.168.0.29:5060</a>
[CS_HANGUP]</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">[NOTICE] mod_dptools.c:600
answer_function() Channel [sofia/internal/<a href="mailto:0000000000@192.168.3.206" target="_blank">0000000000@192.168.3.206</a>] has been
answered</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<div>
<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">
<hr align="center" size="2" width="100%">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">
<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>
[mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b><span style="font-weight: bold;">On Behalf Of </span></b>Anthony Minessale<br>
<b><span style="font-weight: bold;">Sent:</span></b> 14 February 2009 17:20<div><div></div><div class="Wj3C7c"><br>
<b><span style="font-weight: bold;">To:</span></b> <a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a><br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [Freeswitch-users]
Problems with Originate</div></div></span></font></p>
</div><div><div></div><div class="Wj3C7c">
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">are you running this as a
dialplan app?<br>
session is a reserved variable name for the session you executed the app on.<br>
<br>
are you using an alternate name for your new session like my_session etc....?<br>
<br>
this works for me, try it yourself.<br>
<br>
var my_session = new Session("sofia/external/<a href="mailto:7003@conference.freeswitch.org" target="_blank">7003@conference.freeswitch.org</a>");<br>
consoleLog("err", "ready: " + my_session.ready() +
"\n");<br>
<br>
<br>
<br>
</span></font></p>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On Sat, Feb 14, 2009 at 7:17 AM, Nik
Middleton <<a href="mailto:nik.middleton@noblesolutions.co.uk" target="_blank">nik.middleton@noblesolutions.co.uk</a>>
wrote:</span></font></p>
<div link="blue" vlink="blue">
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Understood.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">However, using the second method, how can I trap on call
failure?</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">If I originate a call and the user is busy, the console
reports this fact, but then the script continues to execute </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">if (session.ready()) {</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">
console_log("notice","Session result=[" + session.cause +
"] \n");</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">
if (session.cause == "USER_BUSY") {</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">
Disposition = "BUSY";</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">
session.Hangup();</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">
}</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">In this case session.cause reports 'NONE' and what's
surprising is that even though the call failed (busy) session.ready returns a
true value.</span></font></p>
<div>
<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">
<hr align="center" size="2" width="100%">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> <a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>
[mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b><span style="font-weight: bold;">On Behalf Of </span></b>Anthony Minessale<br>
<b><span style="font-weight: bold;">Sent:</span></b> 13 February 2009 13:55</span></font></p>
<div>
<p><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"><br>
<b><span style="font-weight: bold;">To:</span></b> <a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a></span></font></p>
</div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">Subject:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Re:
[Freeswitch-users] Problems with Originate</span></font></p>
</div>
<div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">The first way is deprecated and will be removed.<br>
The 2nd way is the correct way.</span></font></p>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On Fri,
Feb 13, 2009 at 5:48 AM, Alexandru Nedelcu <<a href="mailto:alex@sinapticode.ro" target="_blank">alex@sinapticode.ro</a>>
wrote:</span></font></p>
<div>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On Fri, 2009-02-13 at 13:33 +0200, Alexandru Nedelcu
wrote:<br>
> The problem with this setup is that origination_caller_id_number doesn't<br>
> work from inside the JS file (when calling session.originate).</span></font></p>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">I just
discovered something interesting.<br>
<br>
When originating the call like this ...<br>
session = new Session("<connection_string>")<br>
instead of this ...<br>
session = new Session();
session.originate("<connection_string>")<br>
<br>
... then it works. Is this some kind of bug, or what's the difference<br>
here?</span></font></p>
<div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><br>
Thanks,<br>
<br>
--<br>
Alexandru Nedelcu<br>
Software Developer, Sinapticode<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></span></font></p>
</div>
</div>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><br>
<br clear="all">
<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>
<br>
AIM: anthm<br>
<a href="mailto:MSN%3Aanthony_minessale@hotmail.com" target="_blank">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com" target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a>
#freeswitch<br>
<br>
FreeSWITCH Developer Conference<br>
<a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:888@conference.freeswitch.org</a><br>
<a href="http://iax:guest@conference.freeswitch.org/888" target="_blank">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org" target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:213-799-1400</span></font></p>
</div>
</div>
</div>
</div>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><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></font></p>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><br>
<br clear="all">
<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>
<br>
AIM: anthm<br>
<a href="mailto:MSN%3Aanthony_minessale@hotmail.com" target="_blank">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com" target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br>
<br>
FreeSWITCH Developer Conference<br>
<a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:888@conference.freeswitch.org</a><br>
<a href="http://iax:guest@conference.freeswitch.org/888" target="_blank">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org" target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:213-799-1400</span></font></p>
</div></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><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
<br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="http://iax:guest@conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:213-799-1400<br>