Fix: Manually serialize ICE candidates for wrtc compatibility

wrtc library doesn't have toJSON() method on RTCIceCandidate.
Manually extract candidate properties instead.
This commit is contained in:
2025-12-12 21:23:40 +01:00
parent 8bb951a91c
commit 778fa2e3a9

View File

@@ -118,10 +118,17 @@ async function main() {
if (event.candidate) {
console.log(' 📤 Sending ICE candidate')
try {
// wrtc doesn't have toJSON, manually create the object
const candidateInit = {
candidate: event.candidate.candidate,
sdpMLineIndex: event.candidate.sdpMLineIndex,
sdpMid: event.candidate.sdpMid,
usernameFragment: event.candidate.usernameFragment
}
await rondevu.getAPIPublic().addOfferIceCandidates(
serviceData.serviceFqn,
serviceData.offerId,
[event.candidate.toJSON()]
[candidateInit]
)
} catch (err) {
console.error(' ❌ Failed to send ICE candidate:', err.message)