Фреймворк Python: щелкните по кнопке «starpy» для вызова, все настроено правильно, но не вызывает, упомянув, что я использую voip.ms.
из URL, который я получаю, чтобы позвонить с этим http://localhost:8000/?number=00593968196867&ext=101
все успешно и соединяется, но просто не звонит
from starpy import manager
from starpy.manager import AMIFactory
from twisted.internet import reactor
from twisted.web import server,resource
import logging
logging.basicConfig()
log = logging.getLogger("Click2Call")
log.setLevel(logging.DEBUG)
manager.log.setLevel(logging.DEBUG)
class Click2CallProtocol(object):
def __init__(self):
pass
def onConnect(self,ami):
log.info("Logged in successfully")
self.ami = ami
def dial(self,number,ext):
try:
# here goes the SIP configuretion details and the number you call
self.ami.originate(channel='Local/101@mycontext',context='mycontext',priority='1',exten=ext,async=True)
return True
except:
return False
class Click2CallFactory(AMIFactory):
def __init__(self):
# the user and password from manager.conf
AMIFactory.__init__(self,"admin","Admin")
def connect(self):
df = self.login("127.0.0.1")
df.addCallback(c2cp.onConnect)
def clientConnectionLost(self,connector,reason):
log.info("We lost connection trying reconnect")
reactor.callLater(1,self.connect)
def clientConnectionFailed(self,connector,reason):
log.info(reason)
reactor.callLater(1,self.connect)
class Click2CallResource(resource.Resource):
def render(self,request):
try:
number = request.args['number'][0]
agent = request.args['ext'][0]
except:
return "Required arguments not found"
if c2cp.dial(agent,number):
return "OK"
else:
return "NOTOK"
c2cp = Click2CallProtocol()
c2cf = Click2CallFactory()
c2cf.connect()
root = Click2CallResource()
root.putChild("",root)
site = server.Site(root)
reactor.listenTCP(8000,site,)
reactor.run()