Fixed glaring WebRTC Negotation bug.

This commit is contained in:
rainbow napkin 2026-10-07 07:43:37 -04:00
parent 29fb28ad5f
commit 6acf7ce54f

View file

@ -93,6 +93,7 @@ class webRTCHandler{
//If we didn't get any audio tracks from the DisplayMedia portion of the API
if(this.broadcastingStream == null || this.broadcastingStream.getAudioTracks().length == 0){
try{
//Bug user for an audio device
const tempStream = await navigator.mediaDevices.getUserMedia({video: false, audio: true});
@ -101,6 +102,9 @@ class webRTCHandler{
//Add to existing broadcast stream
this.broadcastingStream.addTrack(track);
}
}catch(err){
console.warn("Unable to get audio for stream!");
}
}
}
@ -231,7 +235,9 @@ class webRTCHandler{
handleIceCandidate(data){
//If we're broadcasting
if(this.isBroadcasting){
//Find the related user object
const user = this.currentViewers.get(data.source.user);
//allow them to handle it
user.handleIceCandidate(data);
//If we're receiving a stream
}else{
@ -267,7 +273,7 @@ class webRTCHandler{
}
handleConnectionState(data){
if(this.currentStream.connectionState == "failed"){
if(!this.isBroadcasting && this.currentStream.connectionState == "failed"){
let icon = document.createElement('img');
icon.src = "/img/rtcerror.png";
@ -355,7 +361,7 @@ class connectedViewer{
await peer.setLocalDescription(answer);
//Setup peer ICE Candidate event listner
peer.addEventListener('icecandidate', this.sendIceCandidate.bind(this));
peer.addEventListener('icecandidate', (event)=>{this.sendIceCandidate(event, socket)});
//Save peer by socket identifier
this.peers.set(socket, peer);
@ -368,14 +374,14 @@ class connectedViewer{
});
}
sendIceCandidate(event){
sendIceCandidate(event, socket){
//If we have a candidate
if(event.candidate != null){
//Send that shit off!
this.client.socket.emit('relayRTCData',{
type: 'candidate',
body: event.candidate,
recipient: this.socket
recipient: socket
});
}
}