[Freeswitch-dev] Need some info about FreeSWITCH

Michal Bielicki michal.bielicki at voiceworks.pl
Fri Aug 29 08:54:59 EDT 2008


On Aug 29, 2008, at 12:38 PM, Евгений Золотов wrote:

> We try to write some script extensions for application  LUA & JS &  
> Perl.
> There are some questions :
>
> 1. Seems, that for use LUA there is no necessity to install  
> lua-5.1.3.tar.gz from
> http://www.lua.org/ftp/, also that LUA environment is built in a  
> kernel of FreeSWITCH. Is it correct?

Yes

>
> 2. In the catalogue scripts it is placed test files:
>
> - 2004.pl
> #!/usr/bin/perl
> freeswitch::console_log('info', "******Perl*********\n");
> my $res = `uname -a`;
> freeswitch::console_log('notice', "OS Info: $res\n");
> 1;
>
> - 2005.lua
> freeswitch.consoleLog( "info", "*************LUA************\n" );
>
> - 2006.js
> console_log( "*************JavaScript************\n" );
> session.answer();
> exit();
>
> also we make in addition:
> $ luac 2005.lua -o 2005.luac
>
> and add extensions into dialplan:
>
> <extension name="2004">
>   <condition field="destination_number" expression="^2004$" >
>     <action application="perl" data="2004.pl" />
>     <action application="answer" />
>     <action application="sleep" data="1000" />
>   </condition>
> </extension>
>
> <extension name="2005">
>   <condition field="destination_number" expression="^2005$" >
>     <action application="lua" data="2005.lua" />
>     <action application="answer" />
>     <action application="sleep" data="1000" />
>   </condition>
> </extension>
>
> <extension name="20051">
>   <condition field="destination_number" expression="^20051$" >
>     <action application="lua" data="2005.luac" />
>     <action application="answer" />
>     <action application="sleep" data="1000" />
>   </condition>
> </extension>
>
> extension name="2006">
>   <condition field="destination_number" expression="^2006$" >
>     <action application="jsrun" data="2006.js" />
>     <action application="sleep" data="1000" />
>   </condition>
> </extension>
>
> We fulfil inquiries SIPp to the corresponding extension:
> $ ./sipp -sn uac -s 2004 -m 1 opos8:5070
> And we takes on FreeSWITCH's console:
>
>
> 2008-08-29 12:28:07 [NOTICE] switch_channel.c:538  
> switch_channel_set_name() New Channel sofia/nat/ 
> sipp at 192.168.2.108:5061 [7ac768e8-2673-465b-98a4-bba7f1f42f80]
> 2008-08-29 12:28:07 [INFO] mod_dialplan_xml.c:228 dialplan_hunt()  
> Processing sipp->2004 in context public
> 2008-08-29 12:28:07 [INFO] switch_cpp.cpp:1050 console_log()  
> ******Perl*********
> 2008-08-29 12:28:07 [NOTICE] switch_cpp.cpp:1050 console_log() OS  
> Info: Linux opos8.altron.lan 2.6.18-53.1.19.el5 #1 SMP Wed May 7  
> 08:20:19 EDT 2008 i686 i686 i386 GNU/Linux
>
> 2008-08-29 12:35:32 [NOTICE] switch_channel.c:538  
> switch_channel_set_name() New Channel sofia/nat/ 
> sipp at 192.168.2.108:5061 [bc778692-309e-43a7-be3d-e4fa8465fc14]
> 2008-08-29 12:35:32 [INFO] mod_dialplan_xml.c:228 dialplan_hunt()  
> Processing sipp->2005 in context public
> 2008-08-29 12:35:32 [INFO] switch_cpp.cpp:1050 console_log()
> *************LUA************
>
> 2008-08-29 12:40:10 [NOTICE] switch_channel.c:538  
> switch_channel_set_name() New Channel sofia/nat/ 
> sipp at 192.168.2.108:5061 [335f6192-fb5a-43ed-91ce-c8c40f3973b7]
> 2008-08-29 12:40:10 [INFO] mod_dialplan_xml.c:228 dialplan_hunt()  
> Processing sipp->20051 in context public
> 2008-08-29 12:40:10 [INFO] switch_cpp.cpp:1050 console_log()
> *************LUA************
>
> LUA script is fulfilled both in initial and in compiled sort...
>
> 2008-08-29 12:41:38 [NOTICE] switch_channel.c:538  
> switch_channel_set_name() New Channel sofia/nat/ 
> sipp at 192.168.2.108:5061 [2feb67bb-d54b-49ba-a9f2-0d10c0fd5044]
> 2008-08-29 12:41:38 [INFO] mod_dialplan_xml.c:228 dialplan_hunt()  
> Processing sipp->2006 in context public
> 2008-08-29 12:41:38 [ERR] switch_core_session.c:1034  
> switch_core_session_execute_application() Invalid Application jsrun
>
> - and that is a strange error, при чём, if to change in  
> extension
> <action application="jsrun" data="2006.js" />
> for:
> <action application="javascript" data="2006.js" />
> that:
>
> 2008-08-29 12:48:16 [NOTICE] switch_channel.c:538  
> switch_channel_set_name() New Channel sofia/nat/ 
> sipp at 192.168.2.108:5061 [1cc1f4d6-2986-4733-a2bf-84806ff0b681]
> 2008-08-29 12:48:16 [INFO] mod_dialplan_xml.c:228 dialplan_hunt()  
> Processing sipp->2006 in context public
> 2008-08-29 12:48:16 [NOTICE] mod_spidermonkey.c:2034  
> session_answer() Channel [sofia/nat/sipp at 192.168.2.108:5061] has  
> been answered
>
> - then error do not arise:
>
> 2008-08-29 12:50:12 [DEBUG] switch_core_state_machine.c:140  
> switch_core_standard_on_execute() sofia/nat/sipp at 192.168.2.108:5061  
> Execute javascript(2006.js)
> 2008-08-29 12:50:12 [DEBUG] 2006.js:1 console_log()
> *************JavaScript***********
>
> But FreeSWITCH tells:
> > help
> ....
> jsrun,jsrun <script> [additional_vars [...]],run a script
> _______________________________________________
> Freeswitch-dev mailing list
> Freeswitch-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org

jsrun is for console, not for dialplan. The syntax of the console is  
not the same as the syntax for the dialplan

Michal Bielicki, COSO, Member of the Board
HaloKwadrat | ul. Polna 46/14, 00-644 Warszawa
t. +48228753290 x 203 | f. +48228753291
michal.bielicki at halokwadrat.pl | w. www.halokwadrat.pl

Knowledge & Low Prices. Guaranteed!

Halo Kwadrat Sp. z o.o.
z siedzibą w Warszawie przy ulicy Polnej 46/14,00-644 Warszawa
wpisana została do rejestru przedsiębiorców prowadzonego przez
Sąd Rejonowy dla M.ST.Warszawy w Warszawie, XII Wydział Krajowego  
Rejestru Sądowego pod numerem
KRS 0000153539. NIP 525-22-59-473
Wysokość kapitału zakładowego: 50000,00 PLN
----------------------------------------------------------------------------
Wiadomość ta jest przeznaczona jedynie dla osoby lub podmiotu  
będącego jej adresatem
i może zawierać poufne lub uprzywilejowane informacje. Zabronione  
jest przeglądanie,
przesyłanie, rozpowszechnianie lub inne wykorzystywanie tych  
informacji, jak również
podejmowanie działań na ich podstawie, przez osoby lub podmioty inne  
niż zamierzony adresat.
Jeżeli otrzymali Państwo tę wiadomość przez pomyłkę, prosimy o  
poinformowanie o tym nadawcy
i usunięcie jej z komputera.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20080829/3f380fae/attachment-0001.html 


More information about the Freeswitch-dev mailing list