Created a remote ICE candidate listener
This commit is contained in:
@@ -235,6 +235,13 @@ console.log("Echo mock frontend loaded");
|
|||||||
sendSignal(lastSignal)
|
sendSignal(lastSignal)
|
||||||
} else if (payload.type == "answer") {
|
} else if (payload.type == "answer") {
|
||||||
handleAnswer(payload)
|
handleAnswer(payload)
|
||||||
|
} else if (payload.type === "candidate" && payload.candidate) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
await pc.addIceCandidate(new RTCIceCandidate(payload.candidate))
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to add remote ICE candidate", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,8 +253,9 @@ console.log("Echo mock frontend loaded");
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc.onicecandidate = e => {
|
rc.onicecandidate = e => {
|
||||||
console.log(" NEW ice candidate!! reprinting SDP ")
|
console.log(" NEW ice candidate!! reprinting SDP for rc ")
|
||||||
console.log(JSON.stringify(rc.localDescription))
|
console.log("ice candidate", e.candidate)
|
||||||
|
sendSignal({ type: "candidate", candidate: e.candidate })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -280,11 +288,15 @@ console.log("Echo mock frontend loaded");
|
|||||||
await rc.setLocalDescription(answer)
|
await rc.setLocalDescription(answer)
|
||||||
console.log("Answer", JSON.stringify(rc.localDescription))
|
console.log("Answer", JSON.stringify(rc.localDescription))
|
||||||
sendSignal(rc.localDescription)
|
sendSignal(rc.localDescription)
|
||||||
|
appendMessage("system", "Sent Answer")
|
||||||
lastSignal = rc.localDescription
|
lastSignal = rc.localDescription
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnswer(answer) {
|
function handleAnswer(answer) {
|
||||||
pc.setRemoteDescription(answer).then(a => console.log("Accepted Answer."))
|
pc.setRemoteDescription(answer).then(a => {
|
||||||
|
console.log("Accepted Answer.")
|
||||||
|
appendMessage("system", "Accepted Answer")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function createChannel() {
|
function createChannel() {
|
||||||
@@ -297,6 +309,7 @@ console.log("Echo mock frontend loaded");
|
|||||||
if (pc.localDescription) {
|
if (pc.localDescription) {
|
||||||
sendSignal(pc.localDescription)
|
sendSignal(pc.localDescription)
|
||||||
lastSignal = pc.localDescription
|
lastSignal = pc.localDescription
|
||||||
|
appendMessage("system", "Sent Offer")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user