tSIP: command line script

tSIP 0.1.75.7 added capability of executing script passed from command line. Previously there was only an option to write/rewrite script to disk and trigger its execution by "pressing" from command line programmable button that had this script assigned.

Example command line:

    tsip.exe /tsip=SCRIPT="QueuePush('dialingQueue', 4444)"  
  

While length of script passed through command line is limited and writing Lua in single line is problematic, this greatly increases flexibility for integration with other application - command line is just easiest way of communication. "Click to call" mechanism is used - if application finds its previous instance it passes parameters to it and quits, otherwise it continues and executes script after startup.

Command line above pushes phone number (4444) to queue named dialingQueue. This queue may be consumed by e.g. "on timer script":

local CALL_TIME_LIMIT = 6 -- seconds
local callTimeVarName = "callTime"
local callState = GetCallState()
--print("Call state: " .. callState .. "\n")
if callState ~= 0 then
	local count, isSet = GetVariable(callTimeVarName)
	if (isSet == 0) then
		print("Unexpected! Call time var not set!\n")
		count = 0
	else
		count = tonumber(count)
	end
	if count > CALL_TIME_LIMIT then
		Hangup()
	else
		count = count + 1
		SetVariable(callTimeVarName, count)
	end
	return
end

local target, isValid = QueuePop("dialingQueue")
if isValid == 1 then
	print(string.format("Calling to queued [%s]\n", target))
	SetVariable(callTimeVarName, "0")
	Call(target)
end  
  

This particular script fetches number from queue and calls to it if there is no active call at the moment. Regardless of call status call time is limited to 6 (CALL_TIME_LIMIT) seconds.

Back to howto list


 "Cookie monsters": 5932959    Parse time: 0.001 s