Browse Source

New video call logic updates

Vijayakrishnan 5 years ago
parent
commit
e78947f2eb

+ 2 - 2
public/css/meeting.css

@@ -131,8 +131,8 @@ h1 {
     justify-content: flex-end;
     justify-content: flex-end;
 }
 }
 .main-view .thumbs .thumb-view {
 .main-view .thumbs .thumb-view {
-    width: 120px;
-    height: 90px;
+    width: 100px;
+    height: 75px;
     border: 1px solid #0d5875;
     border: 1px solid #0d5875;
     box-shadow: 0 0 3px #888;
     box-shadow: 0 0 3px #888;
     border-radius: 3px;
     border-radius: 3px;

+ 1 - 1
resources/views/checkin.blade.php

@@ -36,7 +36,7 @@
                 if(_data.success) {
                 if(_data.success) {
                     Cookies.set('sessionKey', _data.data.sessionKey, {expires: 365});
                     Cookies.set('sessionKey', _data.data.sessionKey, {expires: 365});
                     Cookies.set('clientUid', _data.data.clientUid, {expires: 365});
                     Cookies.set('clientUid', _data.data.clientUid, {expires: 365});
-                    // window.location = '/client/dashboard';
+                    window.location = '/client/dashboard';
                 }
                 }
                 else {
                 else {
                     new Noty({
                     new Noty({

+ 35 - 20
resources/views/client-dashboard.blade.php

@@ -16,7 +16,7 @@
             <div class="py-3 text-center" v-if="started">
             <div class="py-3 text-center" v-if="started">
                 <h6 class="text-black font-weight-bold m-0">Call in progress: @{{ timeDisplay() }}</h6>
                 <h6 class="text-black font-weight-bold m-0">Call in progress: @{{ timeDisplay() }}</h6>
             </div>
             </div>
-            <div class="py-3 text-center" v-if="!pro || !started">
+            <div class="py-3 text-center" v-if="noOneElseInCall">
                 <h6 class="text-black font-weight-bold m-0">A pro may pop in here at the next chance. Please wait..</h6>
                 <h6 class="text-black font-weight-bold m-0">A pro may pop in here at the next chance. Please wait..</h6>
             </div>
             </div>
             <div class="main-view mx-auto">
             <div class="main-view mx-auto">
@@ -73,7 +73,9 @@
                 readyToPublish: false,
                 readyToPublish: false,
                 publishing: false,
                 publishing: false,
 
 
-                selfUserType: 'CLIENT'
+                selfUserType: 'CLIENT',
+                selfStreamId: '',
+                noOneElseInCall: true,
             },
             },
             methods: {
             methods: {
                 timeDisplay: function() {
                 timeDisplay: function() {
@@ -151,15 +153,9 @@
                             self.pro = true;
                             self.pro = true;
                         }
                         }
 
 
-                        if(!self.startTime) {
-                            self.startTime = new Date().getTime();
-                            window.setInterval(function() {
-                                self.time = new Date().getTime() - self.startTime;
-                            }, 1000);
-                            self.started = true;
-                        }
-
                         self.activateParty(event.stream.id);
                         self.activateParty(event.stream.id);
+
+                        self.noOneElseInCall = false;
                     });
                     });
 
 
                     // peer disconnected
                     // peer disconnected
@@ -177,7 +173,7 @@
                         console.log('onPeerDisconnection');
                         console.log('onPeerDisconnection');
 
 
                         if(event.stream && $('.full-view[data-stream="' + event.stream.id + '"]').length) {
                         if(event.stream && $('.full-view[data-stream="' + event.stream.id + '"]').length) {
-                            var allThumbs = $('.thumbs [data-stream]:not([data-stream=""]):visible');
+                            var allThumbs = $('.thumbs [data-stream]:not([data-stream=""]):not(.disconnected-view):visible');
                             if(allThumbs.length) {
                             if(allThumbs.length) {
                                 $('.thumbs [data-stream]:not([data-stream=""])').each(function() {
                                 $('.thumbs [data-stream]:not([data-stream=""])').each(function() {
                                     if($(this).attr('data-stream') !== event.stream.id) {
                                     if($(this).attr('data-stream') !== event.stream.id) {
@@ -193,19 +189,30 @@
 
 
                         if(event.stream) {
                         if(event.stream) {
                             var remoteViewElem = $('[data-stream="' + event.stream.id + '"]');
                             var remoteViewElem = $('[data-stream="' + event.stream.id + '"]');
-                            if(remoteViewElem.length) {
-                                remoteViewElem.attr('data-stream', '');
-                                remoteViewElem.attr('data-connection-data', '');
-                                remoteViewElem.attr('data-type', '');
-                                remoteViewElem.attr('data-name', '');
-                            }
-                            remoteViewElem.addClass('disconnected-view')
+                            remoteViewElem.remove();
+                            // if(remoteViewElem.length) {
+                            //     remoteViewElem.attr('data-stream', '');
+                            //     remoteViewElem.attr('data-connection-data', '');
+                            //     remoteViewElem.attr('data-type', '');
+                            //     remoteViewElem.attr('data-name', '');
+                            // }
+                            // remoteViewElem.addClass('disconnected-view')
                         }
                         }
 
 
                         // if no other parties in call, hang up
                         // if no other parties in call, hang up
-                        if(!$('[data-stream]:not([data-stream=""])').length) {
+                        if(!$('[data-stream]:not([data-stream="' + self.selfStreamId + '"])').length) {
                             // self.hangUp();
                             // self.hangUp();
-                            console.warn('No other parties in the call!')
+                            console.warn('No other parties in the call!');
+                            new Noty({
+                                theme: 'mint',
+                                type: 'info',
+                                text: 'All other participants have left the call',
+                                progressBar: false,
+                                timeout: false,
+                            }).show();
+                            self.startTime = 0;
+                            self.started = false;
+                            self.noOneElseInCall = true;
                         }
                         }
                     }
                     }
 
 
@@ -228,8 +235,16 @@
                         var selfView = $('#self-view');
                         var selfView = $('#self-view');
                         selfView.attr('data-stream', event.stream.id);
                         selfView.attr('data-stream', event.stream.id);
                         selfView.attr('data-type', 'CLIENT');
                         selfView.attr('data-type', 'CLIENT');
+                        self.selfStreamId = event.stream.id;
                         self.activateParty('self');
                         self.activateParty('self');
                         $('#self-view').show();
                         $('#self-view').show();
+
+                        self.startTime = new Date().getTime();
+                        window.setInterval(function() {
+                            self.time = new Date().getTime() - self.startTime;
+                        }, 1000);
+                        self.started = true;
+
                     });
                     });
 
 
                     self.publisher.on('streamDestroyed', function(event) {
                     self.publisher.on('streamDestroyed', function(event) {

+ 24 - 10
resources/views/pro-call.blade.php

@@ -64,6 +64,7 @@
                 otSession: false,
                 otSession: false,
 
 
                 selfUserType: 'PRO',
                 selfUserType: 'PRO',
+                selfStreamId: '',
                 patientInQueue: false,
                 patientInQueue: false,
 
 
                 videoActive: false
                 videoActive: false
@@ -226,7 +227,7 @@
                     function onPeerDisconnection(event, data) {
                     function onPeerDisconnection(event, data) {
 
 
                         if(event.stream && $('.full-view[data-stream="' + event.stream.id + '"]').length) {
                         if(event.stream && $('.full-view[data-stream="' + event.stream.id + '"]').length) {
-                            var allThumbs = $('.thumbs [data-stream]:not([data-stream=""]):visible');
+                            var allThumbs = $('.thumbs [data-stream]:not([data-stream=""]):not(.disconnected-view):visible');
                             if(allThumbs.length) {
                             if(allThumbs.length) {
                                 $('.thumbs [data-stream]:not([data-stream=""])').each(function() {
                                 $('.thumbs [data-stream]:not([data-stream=""])').each(function() {
                                     if($(this).attr('data-stream') !== event.stream.id) {
                                     if($(this).attr('data-stream') !== event.stream.id) {
@@ -242,13 +243,14 @@
 
 
                         if(event.stream) {
                         if(event.stream) {
                             var remoteViewElem = $('[data-stream="' + event.stream.id + '"]');
                             var remoteViewElem = $('[data-stream="' + event.stream.id + '"]');
-                            if(remoteViewElem.length) {
-                                remoteViewElem.attr('data-stream', '');
-                                remoteViewElem.attr('data-connection-data', '');
-                                remoteViewElem.attr('data-type', '');
-                                remoteViewElem.attr('data-name', '');
-                            }
-                            remoteViewElem.addClass('disconnected-view')
+                            remoteViewElem.remove();
+                            // if(remoteViewElem.length) {
+                            //     remoteViewElem.attr('data-stream', '');
+                            //     remoteViewElem.attr('data-connection-data', '');
+                            //     remoteViewElem.attr('data-type', '');
+                            //     remoteViewElem.attr('data-name', '');
+                            // }
+                            // remoteViewElem.addClass('disconnected-view')
                         }
                         }
 
 
                         var connectionData = JSON.parse(data);
                         var connectionData = JSON.parse(data);
@@ -257,7 +259,18 @@
                         }
                         }
 
 
                         // if no other parties in call, hang up
                         // if no other parties in call, hang up
-                        if(!$('[data-stream]:not([data-stream=""])').length) {
+                        if(!$('[data-stream]:not([data-stream="' + self.selfStreamId + '"])').length) {
+                            // self.hangUp();
+                            console.warn('No other parties in the call!');
+                            new Noty({
+                                theme: 'mint',
+                                type: 'info',
+                                text: 'All other participants have left the call',
+                                progressBar: false,
+                                timeout: 2500,
+                            }).show();
+                            self.startTime = 0;
+                            self.started = false;
                             self.hangUp();
                             self.hangUp();
                         }
                         }
                     }
                     }
@@ -285,6 +298,7 @@
                         var selfView = $('#self-view');
                         var selfView = $('#self-view');
                         selfView.attr('data-stream', event.stream.id);
                         selfView.attr('data-stream', event.stream.id);
                         selfView.attr('data-connection-data', event.stream.connection.data);
                         selfView.attr('data-connection-data', event.stream.connection.data);
+                        self.selfStreamId = event.stream.id;
                     });
                     });
 
 
                     publisher.on('streamCreated', function(event) {
                     publisher.on('streamCreated', function(event) {
@@ -301,7 +315,7 @@
                         event.preventDefault();
                         event.preventDefault();
                         console.log('publisher->streamDestroyed');
                         console.log('publisher->streamDestroyed');
                         $('#self-view').hide();
                         $('#self-view').hide();
-                        var allThumbs = $('.thumbs [data-stream]:not([data-stream=""]):visible');
+                        var allThumbs = $('.thumbs [data-stream]:not([data-stream=""]):not(.disconnected-view):visible');
                         if(allThumbs.length) {
                         if(allThumbs.length) {
                             $('.thumbs [data-stream]:not([data-stream=""])').each(function() {
                             $('.thumbs [data-stream]:not([data-stream=""])').each(function() {
                                 if($(this).attr('data-stream') !== $('#self-view').attr('data-stream')) {
                                 if($(this).attr('data-stream') !== $('#self-view').attr('data-stream')) {