Bläddra i källkod

chrome bug

master
Roderic Day 4 år sedan
förälder
incheckning
233a00645d
2 ändrade filer med 10 tillägg och 9 borttagningar
  1. +8
    -4
      apps/rpc.js
  2. +2
    -5
      apps/video.js

+ 8
- 4
apps/rpc.js Visa fil

@@ -1,5 +1,10 @@
const allRPCs = {}

// ensure no data gets lost when sent through the wire
function K(obj) {
return JSON.parse(JSON.stringify(obj))
}

// https://stackoverflow.com/a/2117523
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
@@ -29,8 +34,7 @@ addEventListener('rpc-needed', ({detail}) => {
const rpc = new RTCPeerConnection(rpcConfig)
rpc.onicecandidate = ({candidate}) => {
if(candidate && candidate.candidate) {
const cand = JSON.parse(JSON.stringify(candidate))
wire({kind: 'ice-candidate', value: {...cand, uid}, target})
wire({kind: 'ice-candidate', value: {...K(candidate), uid}, target})
}
}
rpc.ontrack = ({streams: [stream]}) => {
@@ -79,7 +83,7 @@ addEventListener('rpc-initiate', async({detail}) => {
const localOffer = await rpc.createOffer()
await rpc.setLocalDescription(localOffer)

wire({kind: 'rpc-offer', value: {...localOffer, uid}, target})
wire({kind: 'rpc-offer', value: {...K(localOffer), uid}, target})
})

addEventListener('rpc-offer', async ({detail}) => {
@@ -101,7 +105,7 @@ addEventListener('rpc-respond', async({detail}) => {
const localAnswer = await rpc.createAnswer()
await rpc.setLocalDescription(localAnswer)

wire({kind: 'rpc-answer', value: {...localAnswer, uid}, target})
wire({kind: 'rpc-answer', value: {...K(localAnswer), uid}, target})
})

addEventListener('rpc-answer', async ({detail}) => {

+ 2
- 5
apps/video.js Visa fil

@@ -45,12 +45,9 @@ const Video = {
}
const Toggle = {
view({attrs: {key, label}}) {
const onclick = async () => {
const onclick = () => {
VideoShare[key] = !VideoShare[key]
await VideoShare.getStream()
State.others.forEach(target =>
signal({kind: 'rpc-needed', value: {kind: 'video', target}})
)
VideoShare.getStream()
}
const checked = VideoShare[key]
return m('label.styled',

Laddar…
Avbryt
Spara