Jelajahi Sumber

Sending sessionKey as clientUid.

Kain_Stropov 5 tahun lalu
induk
melakukan
9dfa83be33

+ 1 - 1
app/Http/Controllers/ClientController.php

@@ -49,6 +49,6 @@ class ClientController extends Controller
         if ($session->meetingParticipant && $session->meetingParticipant->meeting->lobby_id === $lobby->id) {
             $meeting = new MeetingModel($session->meetingParticipant->meeting);
         }
-        return view('client/index',compact('lobbyModel','meeting'));
+        return view('client/index',compact('lobbyModel','meeting','sessionKey'));
 	}
 }

+ 42 - 39
resources/js/components/pages/ClientEntrance.vue

@@ -130,18 +130,22 @@ export default {
         },
         meetingProp: {
             type: Object
+        },
+        clientUid: {
+            type: String,
+            required: true
         }
     },
     data() {
         return {
             user: {
-                firstName: '',
-                lastName: '',
+                firstName: "",
+                lastName: "",
                 dateOfBirth: null
             },
-            meetingUid: '',
-            meetingName: sessionStorage.getItem('meeting_name') || '',
-            stepper: sessionStorage.getItem('step') || 1,
+            meetingUid: "",
+            meetingName: sessionStorage.getItem("meeting_name") || "",
+            stepper: sessionStorage.getItem("step") || 1,
             cameraWorkingConfirmed: false,
             loading: false,
             /* Copied */
@@ -196,14 +200,14 @@ export default {
         },
         stepper: {
             handler(newVal) {
-                sessionStorage.setItem('step', newVal)
+                sessionStorage.setItem("step", newVal);
             }
         }
     },
     methods: {
         checkIn() {
             this.loading = true;
-            this.meetingName = `${this.user.firstName} ${this.user.lastName} ${this.user.dateOfBirth}`
+            this.meetingName = `${this.user.firstName} ${this.user.lastName} ${this.user.dateOfBirth}`;
 
             $.ajax({
                 url: "/post-to-api",
@@ -224,19 +228,19 @@ export default {
                     this.stepper = 2;
                     this.meetingUid = data.data;
 
-                    this.$socket.emit('userData', {
+                    this.$socket.emit("userData", {
                         user: {
-                            uid: 'someuid',
+                            uid: "someuid",
                             name: `${this.firstName} ${this.lastName}`,
-                            type: 'STRANGER'
+                            type: "STRANGER"
                         },
                         meeting: {
                             uid: this.meetingUid,
                             lobby_uid: this.lobbyProp.uid
                         }
-                    })
+                    });
 
-                    if(!this.publisher){
+                    if (!this.publisher) {
                         this.$nextTick(this.initializePublisher);
                     }
                 },
@@ -274,20 +278,19 @@ export default {
                             this.$set(cont, "self", true);
                             this.cameraWorkingConfirmed = true;
 
-                            this.$socket.emit('meetingJoined',
-                                {
-                                    lobby_uid: this.lobbyProp.uid,
-                                    meeting_name: this.meetingName,
-                                    meeting_uid: this.meetingUid,
-                                    user: {
-                                        name: `${this.firstName} ${this.lastName}`,
-                                        type: 'STRANGER',
-                                        uid: 'someuid' //TODO:
-                                    }
-                                })
-
-                            if(this.stepper == 3){
-                                this.gotoStep3()
+                            this.$socket.emit("meetingJoined", {
+                                lobby_uid: this.lobbyProp.uid,
+                                meeting_name: this.meetingName,
+                                meeting_uid: this.meetingUid,
+                                user: {
+                                    name: `${this.firstName} ${this.lastName}`,
+                                    type: "STRANGER",
+                                    uid: this.clientUid
+                                }
+                            });
+
+                            if (this.stepper == 3) {
+                                this.gotoStep3();
                             }
                         });
                     }
@@ -303,7 +306,7 @@ export default {
             });
         },
         gotoStep3() {
-            if(this.stepper != 3){
+            if (this.stepper != 3) {
                 this.stepper = 3;
             }
 
@@ -616,33 +619,33 @@ export default {
         }
     },
     created() {
-        if(this.meetingProp){
-            this.user.firstName = this.meetingProp.strangerFirstName
-            this.user.lastName = this.meetingProp.strangerLastName
-            this.user.dateOfBirth = this.meetingProp.strangerDob
+        if (this.meetingProp) {
+            this.user.firstName = this.meetingProp.strangerFirstName;
+            this.user.lastName = this.meetingProp.strangerLastName;
+            this.user.dateOfBirth = this.meetingProp.strangerDob;
 
-            if(this.stepper == 1){
-                this.stepper = 2
+            if (this.stepper == 1) {
+                this.stepper = 2;
             }
 
-            this.$socket.emit('userData', {
+            this.$socket.emit("userData", {
                 user: {
-                    uid: 'someuid',
+                    uid: "someuid",
                     name: `${this.firstName} ${this.lastName}`,
-                    type: 'STRANGER'
+                    type: "STRANGER"
                 },
                 meeting: {
                     uid: this.meetingUid,
                     lobby_uid: this.lobbyProp.uid
                 }
-            })
+            });
         }
     },
     mounted() {
-        if(this.meetingProp){
+        if (this.meetingProp) {
             this.meetingUid = this.meetingProp.uid;
             this.$nextTick(this.initializePublisher);
-            let self = this
+            let self = this;
         }
 
         let self = this;

+ 1 - 0
resources/views/client/index.blade.php

@@ -4,6 +4,7 @@
     <client-entrance 
         :lobby-prop="{!! str_replace('"','\'',str_replace('\'','\\\'',json_encode($lobbyModel))) !!}"
         :meeting-prop="{!! str_replace('"','\'',str_replace('\'','\\\'',json_encode($meeting))) !!}"
+        client-uid="{{ $sessionKey }}"
     ></client-entrance>
 </v-app>
 @endsection