浏览代码

Hang up on pro side if patient gets disconnected

Vijayakrishnan Krishnan 5 年之前
父节点
当前提交
23156808d9
共有 1 个文件被更改,包括 15 次插入4 次删除
  1. 15 4
      resources/views/meet.blade.php

+ 15 - 4
resources/views/meet.blade.php

@@ -152,7 +152,12 @@
                 },
                 hangUp: function() {
                     if(this.otSession) {
-                        this.otSession.disconnect();
+                        try {
+                            this.otSession.disconnect();
+                        }
+                        catch (e) {
+                            console.log('Was already disconnected.');
+                        }
                         this.otSession = false;
                         this.otSessionId = '';
                         this.started = false;
@@ -288,22 +293,28 @@
 
                         self.activateParty('self');
 
+                        @if(!$guest)
+                        if(event.target.connection.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($guest)
-                        self.pro = false;
+                            self.pro = false;
                         @else
-                        self.client = false;
+                            self.client = false;
                         @endif
 
                         // if no other parties in call, hang up
                         if(!$('[data-stream]:not([data-stream=""])').length) {
                             self.hangUp();
                         }
+
                     });
 
                     // self connected