Ruby script: /var/kamailio/ruby/test.rb
def pv_get(pvn)
KSR::PV.get(pvn)
end
def log(mess)
KSR.info(mess.to_s)
end
def pv_set(pvn, val, type)
case type
when :i
KSR::PV.seti(pvn, val)
when :s
KSR::PV.sets(pvn, val)
end
end
def sl_reply(code, mess)
KSR::SL.sl_send_reply(code, mess)
end
def start
income = {}
['$rm', '$ci', '$si', '$rU', '$rd', '$ft'].each do |pv|
income[pv[1..-1].to_sym] = pv_get(pv)
end
log("RUBY - #{KSR.is_INVITE} - #{pv_get('$si')}")
log(income.to_s)
pv_set('$var(tmp)', 12345, :i)
sl_reply(200, 'OK-Ruby')
end
kamailio.cfg is default except:
loadmodule "app_ruby.so"
.....
modparam("app_ruby", "load", "/var/kamailio/ruby/test.rb")
....
# handle requests within SIP dialogs
route(WITHINDLG);
### only initial requests (no To tag)
# authentication
route(AUTH);
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
remove_hf("Route");
if (is_method("INVITE|SUBSCRIBE")) {
record_route();
if(!ruby_run("start")) {
xlogl("L_INFO","SCRIPT: failed to execute ruby function! start");
}
xlog("L_INFO","RUBY -- $var(tmp)");
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.