twilio连接浏览器到浏览器立即挂在js

时间:2016-04-06 16:14:46

标签: twilio

我试图获得一些帮助,因为我不得不用Twilio浏览器拨打电话进行浏览。事实上,浏览器之间存在连接,但会立即挂起。

这是有人试图打电话给支持时创建的twilm。

if(this.request.body.user == "client"){
      var client = this.request.body.agent;
      console.log(client);
      var xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
      xmlData += "<Response>";
      xmlData += "<Dial>";
      xmlData += "<Client CallStatus =\"ringing in-progress busy failed no-answerstatus\" CallbackEvent=\"initiated ringing answered completed\" ";
      xmlData += "statusCallback=\"http://rok.io/events\" ";
      xmlData += "statusCallbackMethod=\"POST\">\""+client+"\"</Client>";
      xmlData += "</Dial>";
      xmlData += "</Response>";
      console.log(xmlData);
      this.response.writeHead(200, {'Content-Type': 'application/xml'});
      this.response.end(xmlData);
  }

这是调用支持的代码

Twilio.Device.setup(token);
     Twilio.Device.ready(function(device){
       console.log("Twilio.Device is now ready for connections");
     });
     setTimeout(function() {
         Twilio.Device.connect({"user":"client","agent":"support_agent"});
     },2000);

最后是支持传入代码

Twilio.Device.setup(token);
     Twilio.Device.ready(function(device){
       console.log("Twilio.Device is now ready for connections");
     });
     Twilio.Device.incoming(function(connect) {
         console.log(connect.parameters.From);
         console.log(connect.status());
         connect.accept();
         console.log(connect.status());

       // Set a callback to be executed when the connection is accepted
     });

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

来自Twilio的梅根在这里。

正如您所提到的,您在<Client>参数中发现了问题。

CallbackEvent应为statusCallbackEvent,如您所见: https://www.twilio.com/docs/api/twiml/client#attributes-status-callback-event

希望如果他们遇到类似问题,这将有助于他人。