博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
给asterisk写app供CLI调用
阅读量:4310 次
发布时间:2019-06-06

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

环境:CentOS6.2 + Asterisk 1.8.7.1

一、添加源文件

复制app_verbose.capp_testApp.c

复制app_verbose.exportsapp_testApp.exports

主要是修改一些标识,编译不会出错就行,这里列出我进行的主要修改。

1、添加头文件

#include "asterisk/cli.h"

2、修改变量

static char *app_testApp = "testApp";static char *app_testApplog = "testAppLog";

3、在load_module中进行注册

res |= ast_register_application_xml(app_testApp, testApp_exec);

4、添加功能函数

static int testApp_exec(struct ast_channel *chan, const char *data){
ast_verb(2,"testApp_exec : %s\r\n",data); return0;}

5、添加cli调用接口

注册commande->command = "testApp {print}";

调用command

if (!strcasecmp(a->argv[1], "print")) {

testApp_exec(chan, a->argv[2]);}

6、在unload_module中进行反注册

res = ast_unregister_application(app_testApp);

二、编译并安装

asterisk -rx "core stop now" && make && make install && asterisk && asterisk -rvvvvvvvvvvvvv 

三、测试

运行asterisk -rvvvvvvvv进入CLI模式

输入:core show help testApp

会输出帮助文档

输入:core show help testApp "something to test!"

会输出:something to test! 

好,就这些了,希望对你有帮助。

转载于:https://www.cnblogs.com/MikeZhang/archive/2012/04/14/asteriskCLIAppTest20120414.html

你可能感兴趣的文章
How it works(2) autocannon源码阅读(A)
查看>>
How it works(3) Tilestrata源码阅读(A)
查看>>
How it works(12) Tileserver-GL源码阅读(A) 服务的初始化
查看>>
uni-app 全局变量的几种实现方式
查看>>
echarts 为例讲解 uni-app 如何引用 npm 第三方库
查看>>
uni-app跨页面、跨组件通讯
查看>>
springmvc-helloworld(idea)
查看>>
JDK下载(百度网盘)
查看>>
idea用得溜,代码才能码得快
查看>>
一篇掌握python魔法方法详解
查看>>
数据结构和算法5-非线性-树
查看>>
数据结构和算法6-非线性-图
查看>>
数据结构和算法7-搜索
查看>>
数据结构和算法8-排序
查看>>
windows缺少dll解决办法
查看>>
JPA多条件动态查询
查看>>
JPA自定义sql
查看>>
BigDecimal正确使用了吗?
查看>>
joplin笔记
查看>>
JNDI+springmvc使用
查看>>