Browse Source

Get & display participant info

Vijayakrishnan 4 năm trước cách đây
mục cha
commit
597ce51077

+ 23 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -257,6 +257,29 @@ class PracticeManagementController extends Controller
         return view('app.video.call', compact('session', 'client'));
     }
 
+    public function getParticipantInfo(Request $request) {
+        $sid = intval($request->get('uid')) - 1000000;
+        $session = AppSession::where('id', $sid)->first();
+        $result = [
+            "type" => '',
+            "name" => ''
+        ];
+        if($session) {
+            $result["type"] = $session->session_type;
+            switch($session->session_type) {
+                case 'PRO':
+                    $pro = Pro::where('id', $session->pro_id)->first();
+                    $result["name"] = $pro->displayName();
+                    break;
+                case 'CLIENT':
+                    $client = Client::where('id', $session->client_id)->first();
+                    $result["name"] = $client->displayName();
+                    break;
+            }
+        }
+        return json_encode($result);
+    }
+
     // ajax ep used by the video page
     // this is needed bcoz meet() is used not
     // just for the client passed to the view

+ 14 - 7
resources/views/app/video/call.blade.php

@@ -63,7 +63,7 @@
                 </h6>
             </div>
             <div class="main-view mx-auto">
-                <div id="self-view" class="full-view" data-name="{{ $pro->name_display }}" data-type="PRO"></div>
+                <div id="self-view" class="full-view" data-name="You" data-type="PRO"></div>
                 <div class="thumbs">
 
                 </div>
@@ -146,6 +146,18 @@
                     ringer: {{ $pro->is_ring_on ? 'true' : 'false' }},
                 },
                 methods: {
+                    resolveParticipantNames: function() {
+                        $('[data-stream]:not([data-name])').each(function() {
+                            let elem = this;
+                            $.post('/pro/meet/get-participant-info', {
+                                _token: '{{ csrf_token() }}',
+                                uid: $(elem).attr('data-stream')
+                            }, function(_data) {
+                                $(elem).attr('data-type', _data.type);
+                                $(elem).attr('data-name', _data.name);
+                            }, 'json');
+                        });
+                    },
                     toggleRinger: function () {
                         let self = this, endPoint = this.ringer ? 'turnOffRing' : 'turnOnRing';
                         $.post('/api/pro/' + endPoint, function (_data) {
@@ -239,6 +251,7 @@
                                 }
                                 self.activateParty(user.uid);
                                 self.noOneElseInCall = false;
+                                self.resolveParticipantNames();
                             })
                             self.agoraClient.on('user-left', user => {
 
@@ -367,12 +380,6 @@
                         return false;
                     });
 
-                    window.onbeforeunload = function () {
-                        if (self.started) {
-                            return "A call is in progress";
-                        }
-                    };
-
                     @if(isset($client))
                         self.client = true;
                         self.clientUid = '{{ $client->uid }}';

+ 1 - 0
routes/web.php

@@ -155,6 +155,7 @@ Route::middleware('pro.auth')->group(function () {
 
     // pro meeting
     Route::get('/pro/meet/{uid?}', 'PracticeManagementController@meet');
+    Route::post('/pro/meet/get-participant-info', 'PracticeManagementController@getParticipantInfo');
     Route::get('/pro/get-opentok-session-key/{uid}', 'PracticeManagementController@getOpentokSessionKey');
     Route::get('/patients-in-queue', 'PracticeManagementController@getPatientsInQueue');
     Route::get('/current-work', 'PracticeManagementController@currentWork');