zoukankan      html  css  js  c++  java
  • [原]FreeSWITCH中的lua操作小结

    lua中设置当前通道变量:
    方法一:
    session:setVariable("fullName", "xxxxx");--需判断session是否为空
    方法二:
    local uuid =getUUID(callerid);
    local res=api:executeString("uuid_setvar ".. uuid .." fullName ".."xxxxxxx")
    该处设置的变量可以是通道中本没有的变量,设置完了后,在其他地方就可以引用该变量。

    lua中设置全局通道变量(在vars.xml中设置)
    local ucall_ip = api:executeString("global_setvar qt_ucall_ip_port 192.168.0.32:9090");

    获取当前的通道变量
    local callee_num=session:getVariable("qt_ucall_callee");

    获取全局通道变量
    local ucall_ip = api:executeString("global_getvar qt_ucall_ip_port");

    获取当前会话uuid
    session:get_uuid()

    获取当前路径
    --USwitch的当前安装目录
    syspath = tostring(api:execute("global_getvar", "base_dir"));

    使用uuid_transfer将当前对话的两个号码同时转入会议中
    local trf1="uuid_transfer " .. guestuuid .. " -both " .. conferenceNum;
    OutputConsoleLog("info" , scriptname ..": try to get guestNum to conference,command is{"..trf1.."}");
    api:executeString(trf1);

    外呼方法总结:
    originate user/11103 139316095XX
    originate sofia/external/139316095XX@192.168.2.34 &playback(calloutmusic/welcometoyou.mp3)
    originate loopback/139316095XX &playback(calloutmusic/20110126164156.mp3)

    在lua脚本中放一段录音
    session:streamFile("notonduty.wav");

    判断会话是否已建立
    session:ready()==true

    挂断当前会话
    session:hangup();

    将当前会话休眠一段时间
    session:sleep(5000);

    发起http请求
    local http = require("socket.http");
    --发起http请求,并获取返回结果
    local e = http.request(url);

  • 相关阅读:
    正则表达式
    http协议组成(请求状态码)
    谈一谈你对js线程的理解
    CSS 中定位方式有几种,说明他们的意义
    手机端白屏前端优化的方法,5 种以上
    用 js 写一个获取随机颜色的程序
    如何获取本地存储信息
    cuda 版本查阅
    ubuntu16.04 ROS安转及RVIZ启动
    Tensorflow和Caffe 简介
  • 原文地址:https://www.cnblogs.com/jizha/p/2231127.html
Copyright © 2011-2022 走看看