问题
I am a junior developer currently working on creating our own phone system with Twilio. At the moment when I initiate a call from the client and the customer picks it up at their end its all working well until the user hangups. The call is still remaining connected until I end the call from the browser. How can I recognise that the user has ended the call from their end?
回答1:
Looks like there is a callback in the Twilio API called "completed"
The call was answered and has ended normally.
Source
回答2:
Danielle, hello! I'm Megan from Twilio.
It sounds like your scenario is related to making outgoing calls from the browser.
Have you followed the steps to hang up calls in the browser? Specifically:
Use .disconnect():
/* Log a message when a call disconnects. */
Twilio.Device.disconnect(function (conn) {
$("#log").text("Call ended");
});
followed by a hangup() function using .disconnectAll():
/* A function to end a connection to Twilio. */
function hangup() {
Twilio.Device.disconnectAll();
}
Consider tracking status from the client connection. When it is closed you can invoke the above functions.
Also, it might help if you turn on debugging in Client via:
Twilio.Device.setup(token, {debug: true});
The Javascript console will show all the low level events received.
Please let me know if this helps.
回答3:
For this I finally resolved it by setting the hub connection back to null on the disconnect.
this.connection.disconnect(() => {
this.connection = null;
});
来源:https://stackoverflow.com/questions/35581184/twilio-recognising-a-user-has-ended-a-call