博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java通过http协议与Freeswitch对接实现动态添加用户
阅读量:2503 次
发布时间:2019-05-11

本文共 2438 字,大约阅读时间需要 8 分钟。

FreeSwitch 支持将话单写入远程的 HTTP 服务器,在哪里你可以使用任何喜欢的编程语言处理话单以及写入任何可能的数据库。有三个模块可以实现他:mod_xml_cdr、mod_json_cdr 以及 mod_format_cdr。前两者分别产生 xml 和 json 格式,最后一个模块则可配置产生 XML 或 JSON 格式。

使用 mod_xml_curl为例:

第一步: 在C:\Program

Files\FreeSWITCH\conf\autoload_configs\modules.conf.xml中释放<load module="mod_xml_curl"/> 的注释。
第二步:② C:\Program
Files\FreeSWITCH\conf\autoload_configs\xml_curl.conf.xml 中添加

中的value指向你的 HTTP 服务器地址。

第三步:创建并开启HTTP服务

//连接FS服务connectFSAndSubscibeFSEvent();ExecutorService  pool = Executors.newCachedThreadPool();server = HttpServer.create(new InetSocketAddress(8080),10);server.createContext("/fsapi/", new DirectoryHandler());//可以通过设置一个线程组由线程来决定执行的过程server.setExecutor(pool);server.start();System.out.println("server started:");

第四步:号码验证

/**	 * @author cyq	 *号码注册认证	 */	class DirectoryHandler implements HttpHandler{		@Override		public void handle(HttpExchange exc) throws IOException {			//String uri=exc.getRequestURI().toString();			//获得输入流			BufferedReader reader=new BufferedReader(new InputStreamReader(exc.getRequestBody()));			//用于存储请求信息  请求参数			String valueString = null;			StringBuilder sbf=new StringBuilder();			while ((valueString=reader.readLine())!=null){				sbf.append(valueString);			} 			String param=sbf.toString();			//System.out.println(param);			String[] str_= param.split("&");			@SuppressWarnings("unused")			String section=null;			String req_key = null;			String req_user = null;			String req_domain = null;			@SuppressWarnings("unused")			String req_ip = null;			String req_callout = null;			String req_pswd = "1234";			for(int i=0;i
" + "
"+ "
"+ "
" + "
"+ "
"+ "
" + "
"+ "
"+ "
"+ "
"+ "
"+ "
" + "
" + "
"+ "
" + "
" + "
" + "
" + "
"+ "
"+ "
"+ "
"+ "
"+ "
"+ "
"+ "
"+ "
"+ "
"+ "
" + "
" + " " + ""; }else{ responseMessage= "
" + "
" + "
" + "
"; } //回应信息 exc.sendResponseHeaders(HttpURLConnection.HTTP_OK, responseMessage.getBytes().length); OutputStream out = exc.getResponseBody(); out.write(responseMessage.getBytes()); out.flush(); exc.close(); } }

无意中发现了一个巨牛的人工智能教程,忍不住分享一下给大家。教程不仅是零基础,通俗易懂,而且非常风趣幽默,像看小说一样!觉得太牛了,所以分享给大家。可以跳转到教程

转载地址:http://xwmgb.baihongyu.com/

你可能感兴趣的文章
linux后台运行命令:&和nohup
查看>>
springboot + shiro学习(配置SecurityManager,Realm)
查看>>
http://desk.zol.com.cn/1600x900/
查看>>
Linux基础之命令练习Day3-文件管理:cat,tar,gzip,vim,ln
查看>>
iOS中使用nil NULL NSNULL的区别
查看>>
Hdu1754-线段树-单点更新
查看>>
在python中使用正则表达式(一)
查看>>
asp.net mvc 4.0的部署
查看>>
WordPress资源站点推荐
查看>>
Python性能鸡汤
查看>>
android Manifest.xml选项
查看>>
Cookie/Session机制具体解释
查看>>
ATMEGA16 IOport相关汇总
查看>>
有意思的cmd命令
查看>>
js正則表達式语法
查看>>
JVM-垃圾回收
查看>>
python中的多继承
查看>>
ubuntu-14.04.1-desktop上安装配置JDK1.8的环境变量
查看>>
VS2013 添加已有文件夹
查看>>
摄影扫盲
查看>>