handler.py 867 B

1234567891011121314151617181920212223242526
  1. import sys
  2. from Router import LM_ERR
  3. class test:
  4. def __init__(self):
  5. LM_ERR('test.__init__\n')
  6. def child_init(self, y):
  7. LM_ERR('test.child_init(%d)\n' % y)
  8. return 0
  9. def handler(self, msg, args):
  10. LM_ERR('test.handler(%s, %s)\n' % (msg.Type, str(arg)))
  11. if msg.Type == 'SIP_REQUEST':
  12. if msg.Method == 'INVITE':
  13. msg.rewrite_ruri('sip:[email protected]:5073')
  14. LM_ERR('SIP request, method = %s, RURI = %s, From = %s\n' % (msg.Method, msg.RURI, msg.getHeader('from')))
  15. LM_ERR('received from %s:%d\n' % msg.src_address)
  16. else:
  17. LM_ERR('SIP reply, status = %s\n' % msg.Status)
  18. LM_ERR('received from %s:%d\n' % msg.src_address)
  19. msg.call_function('append_hf', 'This-is: test\r\n')
  20. return 1
  21. def mod_init():
  22. return test()