在浏览器到浏览器中,当Bob没有接听到Alice的电话时,Alice没有收到任何应答并断开与Bob的联系,但Bob从未知道Alice已断开连接。
Bob如何知道Alice已断开连接?
爱丽丝:
var connection;
Twilio.Device.setup(token);
Twilio.Device.connect(onConnect);
Twilio.Device.disconnect(onDisconnect);
function onConnect(conn) {
connection = conn;
console.log("onConnect: " + connection.status()); //onConnect: open
};
function onDisconnect() {
connection.disconnect();
console.log("onDisconnect: " + connection.status()); //onDisconnect: closed
}
$('.close').one("click", function() {
Twilio.Device.disconnectAll();
});
$(document).ready(function () {
Twilio.Device.connect({
agent: 'bob'
});
});
鲍勃:
var connection;
Twilio.Device.setup(token);
Twilio.Device.incoming(onIncoming);
Twilio.Device.disconnect(onDisconnect);
function onIncoming(conn) {
connection = conn;
console.log("onIncoming: " + connection.status()); //onIncoming: pending
}
//never arrives here when caller disconnect
function onDisconnect() {
console.log("onDisconnect: " + connection.status());
}