ice: event.candidate,
hostPubKey: hpk.n, /* TODO: do we need to send this? */
clientPubKey: offer.pubKey,
- iceCandidateAvailable: true
+ iceState: "a"
}))
}
else {
console.log('Host: Finished sending ICE candidates')
+ console.log(hpc)
}
}
console.log('Host: Sending answer to Client')
})
})
-
-
}
function handleNewIceSubmission(msg) {
function handleIceRequest(msg) {
console.log('Host: Handling ice candidate request')
console.log(iceCandidates)
- const hpc = clients.get(msg)
+ const hpc = clients.get(msg.pubKey)
const iceCandidate = iceCandidates.pop()
if (iceCandidate !== undefined) {
wsock.send(iceCandidate)
} else {
- wsock.send(`{"cmd" : "< ice pubKey", "clientPubKey":"${msg.pubKey}", "iceCandidateAvailable": false}`)
+ if (hpc.iceGatheringState.localeCompare('gathering') === 0) {
+ wsock.send(`{"cmd" : "< ice pubKey", "clientPubKey":"${msg.pubKey}", "iceState": "g"}`)
+ }
+ else if (hpc.iceGatheringState.localeCompare('complete') === 0) {
+ wsock.send(`{"cmd" : "< ice pubKey", "clientPubKey":"${msg.pubKey}", "iceState": "c"}`)
+ }
+
}
}