Hi, this little script redirects all the sip requests it receives to other sip server residing and 192.168.1.100, this is a learning example for me as well, but good enough to start with SIP in twisted.

from twisted.internet import reactor

from twisted.protocols import sip

from twisted.internet.protocol import ServerFactory

class SipProxy(sip.Proxy):
  def __init__(self):
  sip.Proxy.__init__(self,host='192.168.1.3',port=5060)
  self.tries=0
  def handle_request(self,message,addr):
  print message.toString()
  print dir(message)
  if message.method=='ACK':return
  r = self.responseFromRequest(301,message)
  r.addHeader("Contact","sip:192.168.1.100:5061") 
  r.creationFinished()
  self.deliverResponse(r)
  print r.toString()
  print addr
  self.tries+=1
 
class sipfactory(ServerFactory):
  protocol=SipProxy

reactor.listenUDP(5060,SipProxy(),'192.168.1.3')
reactor.run()


Thanks & Regards,

Godson Gera

On 6/30/08, Rémi BUISSON <buisson@enseirb.fr> wrote:
Hi everyone,

I didn't succeed in using twisted.protocols.sip ?

Do you have a simple example for me ? It will be very nice ...

Thanks in advance !

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python