On 08/07/2016 03:13 PM, Anthony Joseph Messina wrote:
I'm trying to play around a bit with app_python
using the examples in the
source. I'd like to access the content of the body of the SIP message, but
can't figure out how to do that. I can get headers, method, etc. How does
one access body content with app_python?
You can pass the appropriate PV ($rb) as the second argument to
python_exec():
http://kamailio.org/docs/modules/4.4.x/modules/app_python.html#idp18178284
In the Python script, you can fish it out with the handler function
called in the first argument to python_exec(). If you're concerned about
delimiters and serialisation, you can base64-encode it with
{s.encode.base64}.
python_exec() only accepts two arguments, so if you need to pass in more
data, your best bet is to use the 'jansson' module to construct a JSON
blob and pass that in as the argument. On the Python side:
import json
...
class WhateverModule:
...
def handler_func(self, msg, args):
obj = json.loads(args)
-- Alex
--
Alex Balashov | Principal | Evariste Systems LLC
1447 Peachtree Street NE, Suite 700
Atlanta, GA 30309
United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)
Web:
http://www.evaristesys.com/,
http://www.csrpswitch.com/