X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fkiak.git;a=blobdiff_plain;f=client.js;h=8813f550da280b974e2ed144858aca2f12288d7c;hp=8989989306690daf5d71a50d675476ad783e2017;hb=d33866cf8b1a188ad9ab23a934986bfd1b4726cb;hpb=d5073d238a4bf9fa96adabf6872a67e6b92fc832 diff --git a/client.js b/client.js index 8989989..8813f55 100644 --- a/client.js +++ b/client.js @@ -7,11 +7,12 @@ document.body = body /* Poll the server. Send get request, wait for timeout, send another request. Do this until...? Can be used for either reconnecting or waiting for answer*/ function pollServerTimeout(url, data, resolve, reject) { - console.log('Polling server with offer ' + data) + console.log(`Polling server ${url} with`) + console.log(data) const request = new XMLHttpRequest() - request.open('GET', url) + request.open('GET', url, true) request.setRequestHeader('Content-Type', 'application/json' ) - request.setRequestHeader('X-Strapp-Type', 'o' ) + request.setRequestHeader('X-Strapp-Type', JSON.stringify(data)) request.onreadystatechange = () => { if (request.status === 200) { console.log(request.response) @@ -26,7 +27,7 @@ function pollServerTimeout(url, data, resolve, reject) { } } console.log(data) - request.send('data in stufff and stuff in data') + request.send() } /* TODO: All this does is wrap a function in a promise */ @@ -76,7 +77,8 @@ const cpc = new RTCPeerConnection() console.log('creating offer') cpc.createOffer().then((offer) => { return cpc.setLocalDescription(offer) -}).then(() => { +}) + .then(() => { console.log('sessionDescriptionInit = ' + cpc.localDescription) getPublicKey().then((cpk) => { console.log('cpk is' + cpk) @@ -95,3 +97,6 @@ cpc.createOffer().then((offer) => { console.log('error in sdp handshake: ' + err) }) }) + .catch((err) => { + console.log(err) + })