|
|
|
@ -151,19 +151,20 @@ const UASimplesIP = (function () {
|
|
|
|
|
session = null; |
|
|
|
|
isIncomingCall = false; |
|
|
|
|
}; |
|
|
|
|
session.on("ended", completeSession); |
|
|
|
|
session.on("failed", completeSession); |
|
|
|
|
session.on("accepted", (accepted) => { |
|
|
|
|
console.log(accepted); |
|
|
|
|
eventoSip.on("failed", completeSession); |
|
|
|
|
|
|
|
|
|
eventoSip.on("ended", () => { |
|
|
|
|
if (session) { |
|
|
|
|
session.terminate(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
session.on("confirmed", function (confirmed) { |
|
|
|
|
console.log( |
|
|
|
|
"confirmed ::::::::::::::::::::::::::::::::::::::::::::::::::::", |
|
|
|
|
confirmed |
|
|
|
|
); |
|
|
|
|
eventoSip.emit("incall"); |
|
|
|
|
const remoteStreams = session.connection.getRemoteStreams()[0]; |
|
|
|
|
remoteAudio.srcObject = remoteStreams; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
session.on("icecandidate", function (event) { |
|
|
|
|
if ( |
|
|
|
|
event.candidate.type === "srflx" && |
|
|
|
@ -174,23 +175,38 @@ const UASimplesIP = (function () {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
session.on("addstream", function (e) { |
|
|
|
|
incomingCallAudio.pause(); |
|
|
|
|
remoteAudio.src = window.URL.createObjectURL(e.stream); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//RECEBENDO UMA CHAMADA
|
|
|
|
|
if (session.direction === "incoming") { |
|
|
|
|
incomingCallAudio.play(); |
|
|
|
|
console.log("::::::::::::::::::::::chamada recebida"); |
|
|
|
|
isIncomingCall = true; |
|
|
|
|
eventoSip.emit("incomingcall", extrairNome(session.remote_identity)); |
|
|
|
|
eventoSip.on("rejected", () => { |
|
|
|
|
incomingCallAudio.pause(); |
|
|
|
|
if (session) { |
|
|
|
|
session.terminate(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
eventoSip.on("accepted", () => { |
|
|
|
|
session.answer(); |
|
|
|
|
incomingCallAudio.pause(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
//REALIZANDO UMA CHAMADA
|
|
|
|
|
if (session.direction === "outgoing") { |
|
|
|
|
console.log("::::::::::::::::::::::chamada realizada"); |
|
|
|
|
eventoSip.emit("outgoingcall"); |
|
|
|
|
} |
|
|
|
|
if (session.direction === "progress") { |
|
|
|
|
eventoSip.emit("incall"); |
|
|
|
|
console.log("::::::::::::::::::::::chamada em progresso"); |
|
|
|
|
} |
|
|
|
|
// //CHAMADA EM ANDAMENTO
|
|
|
|
|
// if (session.direction === "progress") {
|
|
|
|
|
// incomingCallAudio.pause();
|
|
|
|
|
// eventoSip.emit("incall");
|
|
|
|
|
// console.log("::::::::::::::::::::::chamada em progresso");
|
|
|
|
|
// }
|
|
|
|
|
}); |
|
|
|
|
phone.start(); |
|
|
|
|
} |
|
|
|
@ -229,24 +245,6 @@ const UASimplesIP = (function () {
|
|
|
|
|
ativaDebug(value); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
encerraChamada: () => { |
|
|
|
|
if (session) { |
|
|
|
|
session.terminate(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
aceitarChamada: () => { |
|
|
|
|
if (session) { |
|
|
|
|
session.accept(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
rejeitarChamada: () => { |
|
|
|
|
if (session) { |
|
|
|
|
session.reject(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
estouRegistradonoPBX: () => { |
|
|
|
|
console.log("estouRegistradonoPBX ::: " + phone.isRegistered()); |
|
|
|
|
}, |
|
|
|
|