-
Notifications
You must be signed in to change notification settings - Fork 5
Module SIP
Before usage, the module must be loaded on lua. You can do this using the require statement (available only in Lua 5.1).
All luasofia modules are loaded using require “luasofia.module_name”
SIP Example:
sip = require "luasofia.sip"
Now you can use the global var sip to invoke the nua module functions. On the examples above we assume this already have been done and the sip module is loaded on the global var sip
All the examples are made inside the nua event callback function, that passes a sip lightuserdata. The sip is quite big, not all the fields on it already has a proxy to handle it, if you need to access some data that is on the sip_t structure and there in no proxy for it, feel free to do the proxy of this filed and contribute :-).
get_proxy(sip_lightudata)
Given a sip lightuserdata, returns the proxy of the sip lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
end
get_proxy_addr(sip_addr_lightudata)
Given a sip_addr lightuserdata, returns the proxy of the sip_addr lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
local from = sip.get_proxy_addr(sip_proxy.sip_from)
end
get_proxy_contact(sip_contact_lightudata)
Given a sip_contact lightuserdata, returns the proxy of the sip_contact lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
local sip_contact = sip.get_proxy_contact(sip_proxy.sip_contact)
end
get_proxy_request(sip_request_lightudata)
Given a sip_request lightuserdata, returns the proxy of the sip_request lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
local sip_request = sip.get_proxy_request(sip_proxy.sip_request)
end
get_proxy_via(sip_via_lightudata)
Given a sip_via lightuserdata, returns the proxy of the sip_via lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
local sip_via= sip.get_proxy_via(sip_proxy.sip_via)
end
get_proxy_status(sip_status_lightudata)
Given a sip_status lightuserdata, returns the proxy of the sip_status lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
local sip_status= sip.get_proxy_status(sip_proxy.sip_status)
end
get_proxy_event(sip_event_lightudata)
Given a sip_event lightuserdata, returns the proxy of the sip_event lightuserdata.
Example:
function (event, status, phrase, ua, nh, sip_lightudata, tags)
local sip_proxy = sip.get_proxy(sip_lightudata)
local sip_event= sip.get_proxy_event(sip_proxy.sip_event)
end