collectInput does not call callback function
Hi folks! I seem to have an odd problem, since it works for all others. From my java script I try to collect user input: session.collectInput( mycb, "digits", 7000, 0); where mycb is a regular function collecting user input: function mycb( session, type, obj, arg ) { console_log( "info", "collect digits \n" ); try { if ( type == "digits" ) { console_log( "info", "digit: "+obj.digit+"\n" ); if ( obj.digit == "#" ) { console_log( "info", "detected pound sign.\n" ); exit = true; return( false ); } dtmf.digits += obj.digit; if ( dtmf.digits.length >= digitmaxlength ) { exit = true; return( false ); } } } catch (e) { console_log( "err", e+"\n" ); } return( true ); } //end function mycb The very first line is a console info message, so I would know the function is actually called. It never happens. Right before collectInput call I have a message playing a prompt, which I can hear. So workflow definitely goes into the collectInput function, and then after 7 seconds it continues with dtmf.digits.length=0 even though I punched in the numbers, of course. Thats another proof the callback function never was called. Has anyone experienced this problem before? I run FS in Windows. Appreciate your help. Regards, Sergei Kamen -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/collectInput-does-not-call-cal... Sent from the freeswitch-users mailing list archive at Nabble.com.
s/"digits"/"dtmf" ? -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Kamen Sent: Saturday, 28 May, 2011 18:48 To: freeswitch-users@lists.freeswitch.org Subject: [Freeswitch-users] collectInput does not call callback function Hi folks! I seem to have an odd problem, since it works for all others. From my java script I try to collect user input: session.collectInput( mycb, "digits", 7000, 0); where mycb is a regular function collecting user input: function mycb( session, type, obj, arg ) { console_log( "info", "collect digits \n" ); try { if ( type == "digits" ) { console_log( "info", "digit: "+obj.digit+"\n" ); if ( obj.digit == "#" ) { console_log( "info", "detected pound sign.\n" ); exit = true; return( false ); } dtmf.digits += obj.digit; if ( dtmf.digits.length >= digitmaxlength ) { exit = true; return( false ); } } } catch (e) { console_log( "err", e+"\n" ); } return( true ); } //end function mycb The very first line is a console info message, so I would know the function is actually called. It never happens. Right before collectInput call I have a message playing a prompt, which I can hear. So workflow definitely goes into the collectInput function, and then after 7 seconds it continues with dtmf.digits.length=0 even though I punched in the numbers, of course. Thats another proof the callback function never was called. Has anyone experienced this problem before? I run FS in Windows. Appreciate your help. Regards, Sergei Kamen -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/collectInput-does-not-call-cal lback-function-tp6414679p6414679.html Sent from the freeswitch-users mailing list archive at Nabble.com. _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I experience a similar problem after exiting a conference and continuing my C# App. Here is how it works. Caller is given options in Session.StreamFile(play_info[i].filename, (int)start_off); If he presses lets say '1' Session.DtmfReceivedFunction is called by FS and caller gets put into a conference. I have conference maintenance events poped in a separate thread. He presses '#' and gets back to the the same menu, but now if he presses '1' or '#'..anything during StreamFile , the Session.DtmfReceivedFunction is no longer called by FS. Once it goes into Get Digits after StreamFile a press of the digit is returned ok. I noticed, if I dont create EventConsumer for the conf maintenace, it works ok. I need it though to have more control over the conference. It smells like a bug. If anyone knows where to look it is probable where a DtmfReceivedFunction callback during playback should occur if the caller is deleted from the conference instead of assuming that the dtmf will be reported by conference:maintenance event. Kris ----- Original Message ----- From: "Grmt" <garmt.noname@gmail.com> To: "'FreeSWITCH Users Help'" <freeswitch-users@lists.freeswitch.org> Sent: Saturday, May 28, 2011 2:18 PM Subject: Re: [Freeswitch-users] collectInput does not call callback function
s/"digits"/"dtmf" ?
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Kamen Sent: Saturday, 28 May, 2011 18:48 To: freeswitch-users@lists.freeswitch.org Subject: [Freeswitch-users] collectInput does not call callback function
Hi folks!
I seem to have an odd problem, since it works for all others. From my java script I try to collect user input:
session.collectInput( mycb, "digits", 7000, 0);
where mycb is a regular function collecting user input:
function mycb( session, type, obj, arg ) { console_log( "info", "collect digits \n" ); try { if ( type == "digits" ) { console_log( "info", "digit: "+obj.digit+"\n" ); if ( obj.digit == "#" ) { console_log( "info", "detected pound sign.\n" ); exit = true; return( false ); }
dtmf.digits += obj.digit;
if ( dtmf.digits.length >= digitmaxlength ) { exit = true; return( false ); } } } catch (e) { console_log( "err", e+"\n" ); } return( true ); } //end function mycb
The very first line is a console info message, so I would know the function is actually called. It never happens. Right before collectInput call I have a message playing a prompt, which I can hear. So workflow definitely goes into the collectInput function, and then after 7 seconds it continues with dtmf.digits.length=0 even though I punched in the numbers, of course. Thats another proof the callback function never was called.
Has anyone experienced this problem before? I run FS in Windows. Appreciate your help.
Regards,
Sergei Kamen
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/collectInput-does-not-call-cal lback-function-tp6414679p6414679.html Sent from the freeswitch-users mailing list archive at Nabble.com.
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Good point grmt! But that is where I am getting confused. What is that second argument? According to collectInput description in wiki ( http://wiki.freeswitch.org/wiki/Session_collectInput http://wiki.freeswitch.org/wiki/Session_collectInput ) it is a "callbackArguments" which in the example given is the last argument (is it? because no more explanation is given): function mycb( session, type, data, arg ) So I take that "dtmf" of the collectInput is arg of the callback function. session.collectInput( mycb, "dtmf", 3000, 0) But why is it a string type in the example? Isn't dtmf defined as an object and then used in callback function as an object? arg.digits += data.digit; At the same time in callback function example type parameter is apparently expected to be a string "dtmf". Is it a coincidence or I am missing something here? If collectInput second parameter is string "dtmf" then it also looks that in callback function it is apparently a second parameter (type). So what is it? Is it an object dtmf which turns as arg parameter in callback function, or it is a string which in callback function turns into type parameter? I took it should be a string turning into "type" of callback function, so it does not matter what string is as long as it is the same. So I made it "digit". If I am missing something here, I'd really appreciate if someone let me know. I also tried it to be just an object (without quotes, in spite of the example), or followed the example exactly. In any case the callback is not happening - the first line of my callback function is a console prompt, which is not printed. Thus is my question. Regards, Sergei Kamen -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/collectInput-does-not-call-cal... Sent from the freeswitch-users mailing list archive at Nabble.com.
Some clarification from a quick inspection of the code: The callback function can be a generic function and possibly be used by other functions that specify a callbackfunction: it can also capture "events". So callbackfunction can be called with two different types: "dtmf" or "events". collectInput will result calling your callbackfunction with type="dtmf". Checking for "digits" is indeed useless ... Note that the last argument(s) of collectInput are optional. What is that second argument? It should be: "an object dtmf which turns as arg parameter in callback function." (I'm guessing a bit here, because I don't know javascript or mod_spidermonkey, and don't know about the quotes and I didn't try it out and I did only a quick inspection of the code). Garmt -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Kamen Sent: Sunday, 29 May, 2011 17:39 To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] collectInput does not call callback function Good point grmt! But that is where I am getting confused. What is that second argument? According to collectInput description in wiki ( http://wiki.freeswitch.org/wiki/Session_collectInput http://wiki.freeswitch.org/wiki/Session_collectInput ) it is a "callbackArguments" which in the example given is the last argument (is it? because no more explanation is given): function mycb( session, type, data, arg ) So I take that "dtmf" of the collectInput is arg of the callback function. session.collectInput( mycb, "dtmf", 3000, 0) But why is it a string type in the example? Isn't dtmf defined as an object and then used in callback function as an object? arg.digits += data.digit; At the same time in callback function example type parameter is apparently expected to be a string "dtmf". Is it a coincidence or I am missing something here? If collectInput second parameter is string "dtmf" then it also looks that in callback function it is apparently a second parameter (type). So what is it? Is it an object dtmf which turns as arg parameter in callback function, or it is a string which in callback function turns into type parameter? I took it should be a string turning into "type" of callback function, so it does not matter what string is as long as it is the same. So I made it "digit". If I am missing something here, I'd really appreciate if someone let me know. I also tried it to be just an object (without quotes, in spite of the example), or followed the example exactly. In any case the callback is not happening - the first line of my callback function is a console prompt, which is not printed. Thus is my question. Regards, Sergei Kamen -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/collectInput-does-not-call-cal lback-function-tp6414679p6416704.html Sent from the freeswitch-users mailing list archive at Nabble.com. _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I have exhausted all possible combinations for the javascript function collectInput paramaters. Function is not called. Although the timeout works and it waits before continues. Could it be that DTMF is not getting through? And accordingly the function is not called. What could be the possible cause? Thanks Sergei Kamen -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/collectInput-does-not-call-cal... Sent from the freeswitch-users mailing list archive at Nabble.com.
participants (3)
-
Grmt
-
Kamen
-
Kris