rtc

minimal webrtc client
git clone https://git.ce9e.org/rtc.git

commit
8d25536fb1a853974eea8b6af014cd706b8473e9
parent
93f7231d8f6692f780f3a5f019faf130c5d0f308
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-03-24 05:41
rtc: handle more connection events (e.g. disconnect)

Diffstat

M www/rtc/rtc.js 11 +++++++++--

1 files changed, 9 insertions, 2 deletions


diff --git a/www/rtc/rtc.js b/www/rtc/rtc.js

@@ -30,6 +30,15 @@
   30    30 		con.addEventListener('icecandidate', function(event) {
   31    31 			patch.post(sender, {'sender': queueUrl, 'data': event.candidate});
   32    32 		});
   -1    33 		con.addEventListener('negotiationneeded', function() {
   -1    34 			makeOffer(sender);
   -1    35 		});
   -1    36 		con.addEventListener('iceconnectionstatechange', function() {
   -1    37 			if (con.iceConnectionState === 'disconnected') {
   -1    38 				video.remove();
   -1    39 				delete cons[sender];
   -1    40 			}
   -1    41 		});
   33    42 		con.addEventListener('track', function(event) {
   34    43 			// TODO: maybe check if already equal?
   35    44 			// TODO: rm image if no video stream
@@ -120,8 +129,6 @@
  120   129 				s = c.con.addTrack(track, localVideo.srcObject);
  121   130 				c.tracks.push(s);
  122   131 			});
  123    -1 
  124    -1 			makeOffer(sender);
  125   132 		}
  126   133 	}
  127   134