Simple example of host LuaResip application

Feel free to ask any questions here.



-- Copyright (c) 2008 Xeepe project http://xeepe.com
-- Under the terms of the MIT License
-- http://www.opensource.org/licenses/mit-license.html

local r = require "resip"
local sleep = r.sleep
r.logInit("debug", "log.txt")

--ToDo - setNonceHelper key

local stack = r.newSipStack()

stack:addUdpTransport( 5060 )
stack:addTcpTransport( 5060 )

local proxy = r.newTU( stack, "tuMain", "app" )

if not proxy then
    return
end

stack:run()
print( "stack started" )
proxy:run()
print( "TU started" )

while true do
    r.sleep( 1000 )
    if service then -- are we running as winservice?
        if service.stopping() then
            break
        end
    else
        local ch = string.upper( string.sub(io.read("*l"),1,1) )
        if ch and ch =="Q"then
            break
        end
    end
end

proxy:shutdown()
print( "TU shutting down..." )
stack:shutdown()
print( "stack shutting down..." )

proxy:join()
print( "TU stopped" )
stack:join()
print( "stack stopped" )