Skip to content

Commit

Permalink
Merge pull request #134 from StarfilesFileSharing/alpha
Browse files Browse the repository at this point in the history
bandaid fix
  • Loading branch information
QuixThe2nd authored Nov 2, 2024
2 parents 1030f75 + b4edd1c commit 4806f92
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/peers/RTCPeers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class RTCPeers {
if (!conns || message.to !== webRTC.peerId) return;
console.log(`WebRTC: (8/12): ${message.from} Received ICE candidate`);
// if (conns.offered && conns.offered.conn.remoteDescription) conns.offered.conn.addIceCandidate(message.iceCandidate).catch(console.error);
if (conns.answered) conns.answered.conn.addIceCandidate(message.iceCandidate).catch(console.error);
// if (conns.answered) conns.answered.conn.addIceCandidate(message.iceCandidate).catch(console.error);
} else console.warn("Unknown message type received", message);
};
}
Expand Down Expand Up @@ -141,12 +141,16 @@ class RTCPeers {
}
};
conn.onnegotiationneeded = async () => {
if (this.peerConnections[from]?.offered?.channel.readyState === "open" || this.peerConnections[from]?.answered?.channel.readyState === "open") return;
try {
if (this.peerConnections[from]?.offered?.channel.readyState === "open" || this.peerConnections[from]?.answered?.channel.readyState === "open") return;

const offer = await conn.createOffer();
await conn.setLocalDescription(offer);
console.log(`WebRTC: (3/12): ${from} Sending offer from`, extractIPAddress(offer.sdp));
this.wsMessage({ offer, to: from, from: this.peerId });
const offer = await conn.createOffer();
await conn.setLocalDescription(offer);
console.log(`WebRTC: (3/12): ${from} Sending offer from`, extractIPAddress(offer.sdp));
this.wsMessage({ offer, to: from, from: this.peerId });
} catch (e) {
console.error(e);
}
};

return { conn, channel };
Expand Down

0 comments on commit 4806f92

Please sign in to comment.