Automatic loading of files as looped modules. For example, calling call.module1.submodule2.submodule3:anyfunc() will load the following files automatically:
- module1.lua -> create table call.module1
- module1/submodule2.lua -> create table call.module1.submodule2
- module1/submodule2/submodule3.lua - create table call.module1.submodule2.submodule3 and return result from anyfunc()
- luarocks
luarocks install call
- copy file to your project
make install
call = require("call")
call:path('/etc/kamailio/modules/');
call:reload()
function ksr_request_route()
call.mymodule:myfunc(params)
call.mymodule.mysubmodule:myfunc(param)
end
call = dofile("/etc/kamailio/modules/call.lua")
call:path('/etc/kamailio/modules/');
call:reload()
function ksr_request_route()
call.mymodule:myfunc(params)
call.mymodule.mysubmodule:myfunc(param)
end
Create dir /etc/kamailio/modules and create file /etc/kamailio/modules/mymodule.lua
local mymodule = call:_metatable()
function mymodule:myfunc(a)
return 1
end
function mymodule:undefined(a)
return 1
end
return mymodule
Create dir /etc/kamailio/modules/mymodule and create file /etc/kamailio/modules/mymodule/mysubmodule.lua
local mysubmodule = call:_metatable()
function mysubmodule:myfunc(a)
return 1
end
function mysubmodule:undefined(a)
return 1
end
return mysubmodule
Or you can see to test dir - with unlimited looping in the directories
make test
make createversion
Set path where modules stored
Get path where modules stored
Clean loaded modules. And runs one complete cycle of garbage collection. Usage when reload kamailio.
Create and return empty module
local foo = call:_metatable()
or
local baa = {}
baa = call:_metatable(baa)
Print author and version
Get version. When p ~= nil then print to stdout
Get or print memory usage in kBytes. When p ~= nil then print to stdout