
FreeSWITCH中的lua *** 作小结
lua中设置当前通道变量:
方法一:
session:setVariable("fullName", "xxxxx");--需判断session是否为空
方法二:
local uuid =getUUID(callerid);
local res=api:executeString("uuid_setvar " uuid " fullName ""xxxxxxx")
该处设置的变量可以是通道中本没有的变量,设置完了后,在其他地方就可以引用该变量。
lua中设置全局通道变量(在varsxml中设置)
local ucall_ip = api:executeString("global_setvar qt_ucall_ip_port 192168032: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/11103139316095XX
originate sofia/external/139316095XX@192168234 &playback(calloutmusic/welcometoyoump3)
originate loopback/139316095XX&playback(calloutmusic/20110126164156mp3)
在lua脚本中放一段录音
session:streamFile("notondutywav");
判断会话是否已建立
session:ready()==true
挂断当前会话
session:hangup();
将当前会话休眠一段时间
session:sleep(5000);
发起>
-- 如果待判断的是一个变量\x0d\\x0d\local t = type(x);\x0d\if t == "number" then\x0d\ -- 是数字\x0d\else if t == "string" then\x0d\ -- 是字符串\x0d\end\x0d\\x0d\-- 如果带判断是一个字符串,要判断是否可以转成数字, 则\x0d\local n = tonumber(x);\x0d\if n then\x0d\ -- n就是得到数字\x0d\else\x0d\ -- 转数字失败,不是数字, 这时n == nil\x0d\end
-- 由于文件是字节流,所以想直接边读边改,反而会造成反复读写保存文件句柄
-- 所以一般还是读入后写入缓存文件,结束后用缓存文件替换文件
-- 当然如果文件不是很大,内存可以一次性直接读入,那就更好做,可以直接 gmatch gsub 匹配行 *** 作
-- 如果文件很大 可以这样 当行读入,优化的话最好 按字节块读入,然后分行处理
-- 附件创建测试文件,按块读入
----------------------------------------
-- func
----------------------------------------
function is_the_line(line)
-- condition judge
return true
end
----------------------------------------
-- main
----------------------------------------
local flag = "A"
local line_break = "\r\n"
local path = [[d:\aatxt]]
local newpath = path[[tmp]]
local ifs = assert(ioopen(path, "r+"))
if ioopen(newpath, "r+") then
print("缓存文件已经存在!\n按Enter键继续,该文件将会被覆盖\n或者按Ctrl+C退出,停止写文件")
osexecute("pause>nul")
end
local ofs = assert(ioopen(newpath, "w+"))
for line in ifs:lines() do
--local cur = ifs:seek()
--ofs:seek("set", cur)
if is_the_line(line) then
ofs:write(lineflagline_break)
end
end
ifs:close()
ofs:close()
print("ok")
以上就是关于FreeSWITCH中的lua *** 作小结全部的内容,包括:FreeSWITCH中的lua *** 作小结、易语言 API 问题、lua 怎么获取输入的是字符还是数字等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)