[Freeswitch-users] Callback to the user in ESL

lakshmanan ganapathy lakindia89 at gmail.com
Mon Nov 30 02:03:59 PST 2009


In the previous reply you told me to use new "OUTBOUND" connection.
But in this post you mention "INBOUND" connection.

That confusion only made me to ask the question once again. Pardon me if I
made any mistake.

Making a new inbound connection does the task. Thanks for that.


On Sat, Nov 28, 2009 at 12:49 AM, Anthony Minessale <
anthony.minessale at gmail.com> wrote:

> I told you to make a new separate inbound connection back to the server
> from your script, do not use the same one thta was tethered to the call
> because its too late to use that one.
>
> Why do I have to answer you twice?
>
>
>
> On Thu, Nov 26, 2009 at 3:27 AM, lakshmanan ganapathy <
> lakindia89 at gmail.com> wrote:
>
>> Hi, Any help or suggestion regarding my previous post. Especially
>>
>>
>> "I also noted that, if I don't receive any events, especially
>> "SERVER_DISCONNECTED", then the connection is in established state, but once
>> I receive the "SERVER_DISCONNECTED" event, the connection is closed. Is it
>> correct??"
>> Here is the program by which I confirmed the above!
>>
>>
>> require ESL;
>> use IO::Socket::INET;
>>
>> my $ip = "192.168.1.222";
>> my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort => '8447',
>> Proto => 'tcp',  Listen => 2,  Reuse => 1 );
>> die "Could not create socket: $!\n" unless $sock;
>> my $con;
>> my $type = "user/";
>>
>> for(;;) {
>>         # wait for any client to connect, a new client will get connected
>> when a new call comes in the dialplan.
>>
>>         my $new_sock = $sock->accept();
>>         # Do fork and let the parent to wait for more clients.
>>
>>         my $pid = fork();
>>         if ($pid) {
>>                 close($new_sock);
>>                 next;
>>         }
>>         # Extract the host of the client.
>>
>>         my $host = $new_sock->sockhost();
>>         # file descriptor for the socket.
>>
>>         my $fd = fileno($new_sock);
>>         print "Host name is $host\n";
>>         # Create object for the ESL connection package to access the ESL
>> functions.
>>
>>         $con = new ESL::ESLconnection($fd);
>>         # Gets the info about this channel.
>>
>>         my $info = $con->getInfo();
>>         my $uuid = $info->getHeader("unique-id");
>>         printf "Connected call %s, from %s to %s\n", $uuid,
>> $info->getHeader("caller-caller-id-number"),
>> $info->getHeader("caller-destination-number");
>>
>>         # Answer the channel.
>>         $con->execute("answer");
>>         # Set the event lock to tell the FS to execute the instructions in
>> the given order.
>>         $con->setEventLock("true");
>>         # Play a file & Get the personal number from the user.
>>
>> $con->execute("playback","/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav");
>>         $con->execute("hangup");
>>
>>         while($con->connected())
>>         {
>>             my $e=$con->recvEvent();
>>             my $ename=$e->getHeader("Event-Name");
>>             print $e->serialize();
>>             print "$ename\n";
>>             print "Connection exists\n";
>>             sleep(1);
>>
>>         }
>>         print
>> "Bye\n------------------------------------------------------------------\n";
>>         close($new_sock);
>> }
>>     I've not registered for any events.
>>     In the above program I'm receiving the SERVER_DISCONNECTED event.
>> Output when receiving event:
>>     Host name is 192.168.1.222
>>     Connected call 022b79f8-d8c0-11de-8d50-596fac84e59e, from 1000 to 9097
>>     Event-Name: SERVER_DISCONNECTED
>>
>>     SERVER_DISCONNECTED
>>     Connection exists
>>     Bye
>>
>> When I comment the recvEvent line, I got the following output.
>>
>>     Host name is 192.168.1.222
>>     Connected call 65b7f64a-d8c0-11de-8d50-596fac84e59e, from 1000 to 9097
>>     Connection exists
>>     Connection exists
>>     Connection exists
>>     Connection exists
>>     Connection exists
>>
>>
>>
>> On Tue, Nov 24, 2009 at 5:57 PM, lakshmanan ganapathy <
>> lakindia89 at gmail.com> wrote:
>>
>>> I've tried the following program as per the suggestion that you've told.
>>> But it seems, no success. Once the connection is closed, I created a new
>>> connection and I send originate to originate a new call. But it is not
>>> working.
>>>
>>> require ESL;
>>> use IO::Socket::INET;
>>> use Data::Dumper;
>>>
>>> my $ip = "192.168.1.222";
>>> my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort =>
>>> '8447',  Proto => 'tcp',  Listen => 2,  Reuse => 1 );
>>> die "Could not create socket: $!\n" unless $sock;
>>>
>>> my $make_call;
>>> my $con;
>>> my $type = "user/";
>>>
>>> for(;;) {
>>>         my $new_sock = $sock->accept();
>>>         my $pid = fork();
>>>         if ($pid) {
>>>                 close($new_sock);
>>>                 next;
>>>         }
>>>         my $host = $new_sock->sockhost();
>>>         my $fd = fileno($new_sock);
>>>         $con = new ESL::ESLconnection($fd);
>>>         my $info = $con->getInfo();
>>>         my $uuid = $info->getHeader("unique-id");
>>>         printf "Connected call %s, from %s to %s\n", $uuid,
>>> $info->getHeader("caller-caller-id-number"),
>>> $info->getHeader("caller-destination-number");
>>>
>>>         $con->filter("Unique-Id", $uuid);
>>>         $con->events("plain", "all");
>>>         $con->execute("answer");
>>>         $con->setEventLock("true");
>>>         my $number=$con->execute("read","2 4
>>> /usr/local/freeswitch/sounds/en/us/callie/conference/8000/conf-pin.wav
>>> accnt_number 5000 #");
>>>         while($con->connected())
>>>         {
>>>                 my $e=$con->recvEvent();
>>>                 my $ename=$e->getHeader("Event-Name");
>>>                 my $app=$e->getHeader("Application");
>>>                 if($ename eq "CHANNEL_EXECUTE_COMPLETE" and $app eq
>>> "read")
>>>                 {
>>>                         my $num=$e->getHeader("variable_accnt_number");
>>>                         print "$num\n";
>>>                         $con->execute("hangup");
>>>                 }
>>>         }
>>>         if(!$con->connected())
>>>         {
>>>                 print "Connection not exists\n";
>>>                 $con = new ESL::ESLconnection($fd);
>>>                 $con->api("originate","user/1000 &park()");
>>>                 print "Hai\n";
>>>         }
>>>         print
>>> "Bye\n------------------------------------------------------------------\n";
>>>         close($new_sock);
>>> }
>>> Output:
>>> Connected call 6b713588-d8c5-11de-8d50-596fac84e59e, from 1000 to 9097
>>> 1000
>>> Connection not exists
>>> Hai
>>> Bye
>>> ------------------------------------------------------------------
>>> The freeswitch log is in
>>> http://pastebin.freeswitch.org/11258
>>>
>>> I also noted that, if I don't receive any events, especially
>>> "SERVER_DISCONNECTED", then the connection is in established state, but once
>>> I receive the "SERVER_DISCONNECTED" event, the connection is closed. Is it
>>> correct??
>>>
>>>
>>>
>>>
>>>
>>> On Tue, Nov 24, 2009 at 1:10 AM, Anthony Minessale <
>>> anthony.minessale at gmail.com> wrote:
>>>
>>>> or open a new outbound connection at the end of your script so you can
>>>> send your originate command.
>>>> Since the channel hanging up will close your existing connection since
>>>> it's only an outbound single session socket.
>>>>
>>>>
>>>> On Mon, Nov 23, 2009 at 11:51 AM, Michael Collins <msc at freeswitch.org>wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 23, 2009 at 3:25 AM, lakshmanan ganapathy <
>>>>> lakindia89 at gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I'm using perl ESL to control the call in freeswitch.
>>>>>> I'm having the following scenario, but not able to get it right.
>>>>>>
>>>>>> Dialplan:
>>>>>> <extension name="outbound_soc">
>>>>>>     <condition field="destination_number" expression="^9097$">
>>>>>>             <action application="set" data="continue_on_fail=true"/>
>>>>>>             <action application="socket" data="192.168.1.222:8447async full"/>
>>>>>>     </condition>
>>>>>> </extension>
>>>>>>
>>>>>>
>>>>>> 1. User A calls to an extention (1000).
>>>>>> 2. My ESL program will be running, and it answers the call.
>>>>>> 3. Then the program will get a number from the user.
>>>>>> 4. It will hangup the call.
>>>>>> 5. The program has to call to the number that was given by the user.
>>>>>>
>>>>>> In the above scenario, I was able to do until the 4th step. After
>>>>>> hangup the call, if I say originate it is not working.
>>>>>> Any ideas on how to do this in ESL.
>>>>>>
>>>>>>
>>>>> I want to make sure I understand what the script is supposed to be
>>>>> doing. The caller will key in a phone number to your script and your script
>>>>> will collect those digits. The script will then hangup on the caller and
>>>>> originate a completely new call? Perhaps you could use sched_api to schedule
>>>>> a new originate command for a few seconds into the future and then hangup?
>>>>> -MC
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> FreeSWITCH-users mailing list
>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>> UNSUBSCRIBE:
>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>> http://www.freeswitch.org
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Anthony Minessale II
>>>>
>>>> FreeSWITCH http://www.freeswitch.org/
>>>> ClueCon http://www.cluecon.com/
>>>> Twitter: http://twitter.com/FreeSWITCH_wire
>>>>
>>>> AIM: anthm
>>>> MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
>>>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
>>>> IRC: irc.freenode.net #freeswitch
>>>>
>>>> FreeSWITCH Developer Conference
>>>> sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
>>>> iax:guest at conference.freeswitch.org/888
>>>> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
>>>> pstn:213-799-1400
>>>>
>>>> _______________________________________________
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> http://www.freeswitch.org
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
>
> --
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
>
> AIM: anthm
> MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
> iax:guest at conference.freeswitch.org/888
> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
> pstn:213-799-1400
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20091130/5e3a1382/attachment-0002.html 


More information about the FreeSWITCH-users mailing list