|
@@ -290,20 +290,31 @@
|
|
|
|
|
|
// peer disconnected
|
|
|
self.otSession.on("streamDestroyed", function(event) {
|
|
|
+ console.log('streamDestroyed from ' + event.target.connection.data);
|
|
|
+ onPeerDisconnection(event, event.stream.connection.data);
|
|
|
+ });
|
|
|
+ self.otSession.on("connectionDestroyed", function(event) {
|
|
|
+ console.log('connectionDestroyed from ' + event.connection.data);
|
|
|
+ onPeerDisconnection(event, event.connection.data);
|
|
|
+ });
|
|
|
|
|
|
+ function onPeerDisconnection(event, data) {
|
|
|
self.activateParty('self');
|
|
|
|
|
|
@if(!$guest)
|
|
|
- if(event.target.connection.data.split('|')[1] === 'CLIENT') {
|
|
|
+ if(data.split('|')[1] === 'CLIENT') {
|
|
|
self.hangUp();
|
|
|
}
|
|
|
@endif
|
|
|
|
|
|
- var remoteViewElem = $('[data-stream="' + event.stream.id + '"]');
|
|
|
- if(remoteViewElem.length) {
|
|
|
- remoteViewElem.attr('data-stream', '');
|
|
|
- remoteViewElem.attr('data-from', '');
|
|
|
+ if(event.stream) {
|
|
|
+ var remoteViewElem = $('[data-stream="' + event.stream.id + '"]');
|
|
|
+ if(remoteViewElem.length) {
|
|
|
+ remoteViewElem.attr('data-stream', '');
|
|
|
+ remoteViewElem.attr('data-from', '');
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
@if($guest)
|
|
|
self.pro = false;
|
|
|
@else
|
|
@@ -314,8 +325,7 @@
|
|
|
if(!$('[data-stream]:not([data-stream=""])').length) {
|
|
|
self.hangUp();
|
|
|
}
|
|
|
-
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
// self connected
|
|
|
self.otSession.on("sessionConnected", function(event) {
|
|
@@ -518,6 +528,12 @@
|
|
|
|
|
|
@endif
|
|
|
|
|
|
+ window.onbeforeunload = function() {
|
|
|
+ if(self.started) {
|
|
|
+ return "A call is in progress";
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
</script>
|