Sunflysp是一个脚本解析程序,能够充当服务器。

安装sunflysp程序:

把sunflysp的执行程序ftp到sunfly/exe目录下,同时把sunflysp的配置文件config.sunflyspa也ftp到sunfly/config目录下。

 config.sunflyspa配置文件说明:

        <config>

        <connect>

                <item name="httpServer1" protocol="P_HTTP">

                        <server port="19800" serviceKey="7" service="//home/zc/sunfly/svc/test/callin"/> <!--该部分启动一个http端口,等待web主动发送脚本业务,收到脚本送到系统业务7中处理-->

                </item>

        </connect>

        <httpUser watchkeeperProxyPort="22223"> <!--该部分配置可以接受哪些web的http请求,平台收到web的http请求验证一下身份-->

                <item name="icp1" passwd="123456" msg="fhdsakjfdsf"/>

                <item name="icp2" passwd="123457" msg="fdsggfdfd"/>

                <item name="icp3" passwd="123458" msg="rewdsfdsfd"/>

        </httpUser>

        <tcap>

                 <address>

                <item name="local">

                         <connectName>mapsm</connectName>

                         <groupId>1</groupId>

                         <pointCode>1235</pointCode>

                         <ssn>100</ssn>

                         <globalTitle type="-1" body="null"/>

                </item>

                <item name="hlr">

                        <connectName>mapsm</connectName>

                        <groupId>1</groupId>

                        <pointCode>1234</pointCode>

                        <ssn>200</ssn>

                        <globalTitle type="-1" body="null"/>

                </item>

                <item name="ip">

                        <connectName>mapsm</connectName>

                        <groupId>1</groupId>

                        <pointCode>1234</pointCode>

                        <ssn>200</ssn>

                        <globalTitle type="-1" body="null"/>

                </item>

                </address>

        <appContext>

                <item name="acn1" value="0|1|2|3|4|5|6|1"/> <!--name的长度不能超过11/-->

                <item name="acn2" value="0|1|2|3|4|5|6|2"/>

                <item name="acn3" value="0|1|2|3|4|5|6|3"/>

                <item name="acn4" value="0|1|2|3|4|5|6|4"/>

                <item name="acn5" value="4|0|0|1|0|1|3"/>

                <item name="acn6" value="18|9|2|132|8|1|0|1|0|5|3|0|0"/>

        </appContext>

        <asn1>

                <dataBase>

                        <item name="cap2_v100"/>

                        <item name="map_v100"/>

                </dataBase>

        </asn1>

        </tcap>

                <sunfly autoTcContinue1="0"> <!--脚本解释器被触发后,是否需要自动回松一个不带成分的tocontinue-->

                <request service="//home/zc/sunfly/svc/test/testService"/>

        </sunfly>

        <watchkeeperRun>

                <command>trace on</command>

        </watchkeeperRun>

</config>

修改配置文件

首先到/sunfly/config目录下打开config.mispa文件配置request的url指向sunflysp程序所在的地址和sunflysp配置文件中启动的一个http端口,等待web主动发送脚本业务

<request url=" http://192.168.1.195:19800/testService">

<getparm name="getFromNum" value="" parm="getFromNum" msg="INVITE"/>

<getparm name="getToNum" value="" parm="getToNum" msg="INVITE"/>

<check msg="INVITE" parm="getReqUrlNum" value="123"/>

</request>

<config>

<connect>

<item name="httpServer1" protocol="P_HTTP">

<server port="19800" serviceKey="7" service="//home/zc/sunfly/svc/test/testService"/>

该部分启动一个http端口,等待web主动发送脚本业务,收到脚本送到系统业务7中处理

</item>

</connect>

<httpUser watchkeeperProxyPort="22223">

<item name="icp1" passwd="123456" msg="fhdsakjfdsf"/>

<item name="icp2" passwd="123457" msg="fdsggfdfd"/>

<item name="icp3" passwd="123458" msg="rewdsfdsfd"/>

</httpUser>

<tcap>

<address>

<item name="local">

<connectName>mapsm</connectName>

<groupId>1</groupId>

<pointCode>1235</pointCode>

<ssn>100</ssn>

<globalTitle type="-1" body="null"/>

</item>

<item name="hlr">

<connectName>mapsm</connectName>

<groupId>1</groupId>

<pointCode>1234</pointCode>

<ssn>200</ssn>

<globalTitle type="-1" body="null"/>

</item>

<item name="ip">

<connectName>mapsm</connectName>

<groupId>1</groupId>

<pointCode>1234</pointCode>

<ssn>200</ssn>

<globalTitle type="-1" body="null"/>

</item>

</address>

<appContext>

<item name="acn1" value="0|1|2|3|4|5|6|1"/> <!--name的长度不能超过11/-->

<item name="acn2" value="0|1|2|3|4|5|6|2"/>

<item name="acn3" value="0|1|2|3|4|5|6|3"/>

<item name="acn4" value="0|1|2|3|4|5|6|4"/>

<item name="acn5" value="4|0|0|1|0|1|3"/>

<item name="acn6" value="18|9|2|132|8|1|0|1|0|5|3|0|0"/>

</appContext>

<asn1>

<dataBase>

<item name="cap2_v100"/>

<item name="map_v100"/>

</dataBase>

</asn1>

</tcap>

<sunfly autoTcContinue1="0">

<request service="//home/zc/sunfly/svc/test/testService"/>

</sunfly>

<watchkeeperRun>

<command>trace on</command>

</watchkeeperRun>

</config>

  编写testService文件

编写testService文件,部署到/sunfly/svc/test目录下,用于业务的处理

/***********************************************************************

123接入,处理请求返回ccxml/vxml

************************************************************************/

string callName;

string testCCXMLfile = "//home/zc/sunfly/svc/test/test.ccxml";

string testVXMLfile = "//home/zc/sunfly/svc/test/test.vxml";

void testCCXML(string url);

void testVXML(string url);

void HttpRequest(string logicalname,httpRequest httpReq) //系统回调函数

{

setInstanceTimeOut(5);

string url = httpReq.getUrl();获得请求url

callName = url.strtok("?");获得当前串前面的部分

if(callName == "/testService")

{

testCCXML(url);

}

else

{

testVXML(url);

}

}

void testCCXML(string url)

{

int fd;

fd = fopen(testCCXMLfile); // 打开文件testCCXMLfile

string testCCXML = fread(fd,0,0); //读取文件并且赋值给 testCCXML

fclose(fd); //关闭一个已经打开的文件

memset("testCCXMLfile",testCCXML); //将testCCXML保存到内存里

string testCCXML1 = memget("testCCXMLfile"); //从平台内存读数据

httpResponse response;

response.setStatusCode(200); //必须第一个设置setStatusCode

response.setBody(testCCXML1);

response.send();

exit();

}

void testVXML(string url)

{

int fd;

fd = fopen(testVXMLfile);

string testVXML = fread(fd,0,0);

fclose(fd);

memset("testVXMLfile",testVXML);

string testVXML1 = memget("testVXMLfile");

httpResponse response;

response.setStatusCode(200); //必须第一个设置setStatusCode

response.setBody(testVXML1);

response.send();

exit();

}

void SeconeDone() //系统回调函数

{

logInfo("$$$$httpRequest1 SeconeDone(",getMyInstance(),getInstance(),")");

}

void DelayDone(string info) //系统回调函数

{

logInfo("$$$$httpRequest1 DelayDone(",info,")");

}

void ErrorDone(string info) //系统回调函数

{

logInfo("$$$$httpRequest1 ErrorDone(",info,")");

exit();

}

编写业务

根据ccxml标准编写test.ccxml脚本,修改xml:base=” http://192.168.1.195:19800/test/”

<?xml version="1.0" encoding="UTF-8"?>

<ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml" xml:base="http://192.168.1.195:19800/ test/">

<var name="state0" expr="'loaded'"/>

<var name="in_connectionid" expr="" />

<eventprocessor statevariable="state0">

<transition event="connection.alerting" name="evt">

<log expr="'connection.alerting' + evt.protocol + ':' + evt.info"/>

<assign name="in_connectionid" expr="evt.connection.connectionid" />

<accept connectionid="in_connectionid"/>

</transition>

<transition event="connection.connected" name="evt">

<log expr="'connection.connected' + evt.protocol + ':' + evt.info"/>

<dialogstart namelist="session.id" connectionid="in_connectionid" src="'testvxml'" />

</transition>

<transition event="dialog.exit" name="evt">

<log expr="'dialog.exit'"/>

<exit/>

</transition>

<transition event="connection.failed" name="evt">

<log expr="'connection.failed' + ' ' + evt.info + ' ' + evt.reason"/>

<exit />

</transition>

<transition event="connection.disconnected">

<log expr="'connection.disconnected connectionid:' + event$.connectionid + ' reason:' + event$.reason + ' info:' + event$.info"/>

<exit />

</transition>

<transition event="error.semantic">

<log expr="'error.semantic'"/>

<exit />

</transition>

</eventprocessor>

</ccxml>

根据vxml标准编写test.vxml脚本,主要实现录音功能,首先播放提示音1234,1234.pcm语音文件存放在/sunfly/vvs目录下,用于提示用户开始录音

<?xml version="1.0" encoding="UTF-8"?>

<vxml version="2.0">

<form id="playandrecord">

<block>

<prompt bargein="true"><audio expr="'1234'"/></prompt>

</block>

<record name="recordfile" beep="true" maxtime="10s" finalsilence="4000m">

<property name="termchar" value="#"/>

<property name="cancelchar" value="*"/>

<property name="replaydigit" value="0"/>

<property name="restartdigit" value="1"/>

<noinput>

<exit namelist="recordfile"/>

</noinput>

<filled>

<exit namelist="recordfile"/>

</filled>

</record>

</form>

</vxml>

业务的部署

最后把编写好的test.ccxml和test.vxml文件部署到sunfly/svc/业务目录下的test项目下,之后执行sunflysp a启动sunflysp程序

[zc@localhost ~]$ sunflysp a

=======================================================

_______________________________________________________

SunFlyFrameWork Application : sunflysp a

SunFlyFrameWork Version : 005.109.082

=======================================================

sunflyspa 21:45:44: open /home/zc/sunfly/exe/fifo/watchkeeper.sunflyspa success

sunflyspa 21:45:44: open /home/zc/sunfly/exe/fifo/sunflyspa.watchkeeper success

<command name="trace">

<info> trace turn on </info>

</command>

sunflyspa 21:45:44: sunflysp005.109.082 startup success

这时候sip电话呼叫123,实现电话和misp平台的交互操作。进而实现录音功能