diff --git a/frontend/WebRTC.ts b/frontend/WebRTC.ts index 8a74957..b8cf4a9 100644 --- a/frontend/WebRTC.ts +++ b/frontend/WebRTC.ts @@ -119,12 +119,15 @@ export default class WebRTC } case "streamAccept":{ let {id} = data; - let {stream} = this.sendingStream.get(id) as {stream:MediaStream}; + let sendingStream = this.sendingStream.get(id) as TransferStreamInfo; let senders = []; - for (const track of stream.getTracks()) { - senders.push(this.rtc.addTrack(track, stream)); - }; - stream.senders = senders; + if(sendingStream && sendingStream.stream) + { + for (const track of sendingStream.stream.getTracks()) { + senders.push(this.rtc.addTrack(track, sendingStream.stream)); + }; + sendingStream.senders = senders; + } break; } case "message":{ @@ -285,7 +288,7 @@ export default class WebRTC { for (const stream of event.streams) { let streamInfo = this.recaivingStream.get(stream.id) as TransferStreamInfo; - streamInfo.recaivers.push(rtpRecaiver); + (streamInfo.recaivers || (streamInfo.recaivers = [])).push(rtpRecaiver); if((this.recaivingStream.get(stream.id) as {stream : MediaStream | undefined}).stream == null) { streamInfo.stream = stream;