zoukankan      html  css  js  c++  java
  • 给asterisk写app供CLI调用

    环境: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! 

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

  • E-Mail : Mike_Zhang@live.com
  • 转载请注明出处,谢谢!
查看全文
  • 相关阅读:
    十个男人看了,九个成了富人
    win7下编译安装osgearth
    gdal源码编译安装
    win7下编译boost库总结
    everything && executor
    cursor:hand与cursor:pointer的区别介绍
    web程序记录当前在线人数
    汉字转拼音
    40多个非常有用的Oracle 查询语句
    asp.net 使用IHttpModule 做权限检查 登录超时检查(转)
  • 原文地址:https://www.cnblogs.com/MikeZhang/p/asteriskCLIAppTest20120414.html
  • Copyright © 2011-2022 走看看