X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fkiak.git;a=blobdiff_plain;f=host.js;h=01c56a2d1c5c77f021074aee402dab717bb60b30;hp=3af3426d8040767e7e806a6cb3d4bc543c8196e7;hb=5da8f7e044a781c15567b43ee9acc07444605015;hpb=44c1e3ad8fd1e594cceebb36a97e3b126b7d6188 diff --git a/host.js b/host.js index 3af3426..01c56a2 100644 --- a/host.js +++ b/host.js @@ -58,11 +58,12 @@ function handleNewClientConnection(offer) { 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') @@ -91,8 +92,6 @@ function handleNewClientConnection(offer) { }) }) - - } function handleNewIceSubmission(msg) { @@ -105,12 +104,18 @@ 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"}`) + } + } }