@@ -17,10 +17,14 @@ import { handleError } from 'src/infrastructure/helpers/error_handler';
17
17
import * as webrtc from 'werift' ;
18
18
import { SentCameraTypeDto } from './dtos/set_camera_type.dto' ;
19
19
import { WebRTCManager } from 'src/infrastructure/services/sfu/webrtc_manager' ;
20
+ import { MeetingGrpcService } from 'src/infrastructure/services/meeting/meeting.service' ;
20
21
21
22
@WebSocketGateway ( )
22
23
export class MeetingGateway {
23
- constructor ( private readonly rtcManager : WebRTCManager ) { }
24
+ constructor (
25
+ private readonly rtcManager : WebRTCManager ,
26
+ private readonly meetingService : MeetingGrpcService ,
27
+ ) { }
24
28
25
29
@WebSocketServer ( ) private server : Server ;
26
30
private logger : Logger = new Logger ( 'MeetingGateway' ) ;
@@ -33,6 +37,12 @@ export class MeetingGateway {
33
37
info : { participantId : payload . participantId , roomId : payload . roomId } ,
34
38
} ) ;
35
39
40
+ const participantInfo = await this . meetingService . getParticipantById ( {
41
+ participantId : payload . participantId ,
42
+ } ) ;
43
+
44
+ if ( ! participantInfo ) return ;
45
+
36
46
const responsePayload = await this . rtcManager . joinRoom (
37
47
client . id ,
38
48
payload . sdp ,
@@ -43,9 +53,7 @@ export class MeetingGateway {
43
53
callback : ( ) => {
44
54
client . broadcast
45
55
. to ( payload . roomId )
46
- . emit ( SocketEvent . newParticipantSSC , {
47
- targetId : payload . participantId ,
48
- } ) ;
56
+ . emit ( SocketEvent . newParticipantSSC , participantInfo ) ;
49
57
} ,
50
58
} ,
51
59
) ;
@@ -113,8 +121,14 @@ export class MeetingGateway {
113
121
114
122
@SubscribeMessage ( SocketEvent . setE2eeEnabledCSS )
115
123
handleSetE2eeEnable ( client : ISocketClient , payload : SetHardwareStatusDto ) {
116
- const roomId = client . data . roomId ;
117
- const targetId = client . data . participantId ;
124
+ const clientInfo = this . rtcManager . getClientBySocketId ( {
125
+ clientId : client . id ,
126
+ } ) ;
127
+
128
+ if ( ! clientInfo ) return ;
129
+
130
+ const roomId = clientInfo . roomId ;
131
+ const targetId = clientInfo . participantId ;
118
132
119
133
if ( ! roomId ) return ;
120
134
@@ -130,8 +144,14 @@ export class MeetingGateway {
130
144
131
145
@SubscribeMessage ( SocketEvent . setCameraTypeCSS )
132
146
handleSetCameraType ( client : ISocketClient , payload : SentCameraTypeDto ) {
133
- const roomId = client . data . roomId ;
134
- const targetId = client . data . participantId ;
147
+ const clientInfo = this . rtcManager . getClientBySocketId ( {
148
+ clientId : client . id ,
149
+ } ) ;
150
+
151
+ if ( ! clientInfo ) return ;
152
+
153
+ const roomId = clientInfo . roomId ;
154
+ const targetId = clientInfo . participantId ;
135
155
136
156
if ( ! roomId ) return ;
137
157
@@ -150,8 +170,14 @@ export class MeetingGateway {
150
170
client : ISocketClient ,
151
171
payload : SetHardwareStatusDto ,
152
172
) : any {
153
- const roomId = client . data . roomId ;
154
- const targetId = client . data . participantId ;
173
+ const clientInfo = this . rtcManager . getClientBySocketId ( {
174
+ clientId : client . id ,
175
+ } ) ;
176
+
177
+ if ( ! clientInfo ) return ;
178
+
179
+ const roomId = clientInfo . roomId ;
180
+ const targetId = clientInfo . participantId ;
155
181
156
182
if ( ! roomId ) return ;
157
183
@@ -170,8 +196,14 @@ export class MeetingGateway {
170
196
client : ISocketClient ,
171
197
payload : SetHardwareStatusDto ,
172
198
) : any {
173
- const roomId = client . data . roomId ;
174
- const targetId = client . data . participantId ;
199
+ const clientInfo = this . rtcManager . getClientBySocketId ( {
200
+ clientId : client . id ,
201
+ } ) ;
202
+
203
+ if ( ! clientInfo ) return ;
204
+
205
+ const roomId = clientInfo . roomId ;
206
+ const targetId = clientInfo . participantId ;
175
207
176
208
if ( ! roomId ) return ;
177
209
@@ -190,8 +222,14 @@ export class MeetingGateway {
190
222
client : ISocketClient ,
191
223
payload : SetScreenSharingDto ,
192
224
) : any {
193
- const roomId = client . data . roomId ;
194
- const targetId = client . data . participantId ;
225
+ const clientInfo = this . rtcManager . getClientBySocketId ( {
226
+ clientId : client . id ,
227
+ } ) ;
228
+
229
+ if ( ! clientInfo ) return ;
230
+
231
+ const roomId = clientInfo . roomId ;
232
+ const targetId = clientInfo . participantId ;
195
233
196
234
if ( ! roomId ) return ;
197
235
@@ -206,7 +244,7 @@ export class MeetingGateway {
206
244
}
207
245
208
246
@SubscribeMessage ( SocketEvent . leaveRoomCSS )
209
- handleLeaveRoom ( client : ISocketClient , payload : any ) : any {
247
+ async handleLeaveRoom ( client : ISocketClient , payload : any ) {
210
248
const info = this . rtcManager . leaveRoom ( { clientId : client . id } ) ;
211
249
212
250
if ( info ) {
@@ -215,6 +253,9 @@ export class MeetingGateway {
215
253
} ) ;
216
254
217
255
client . leave ( info . roomId ) ;
256
+
257
+ const succeed = await this . meetingService . leaveRoom ( info ) ;
258
+ this . logger . debug ( `Update leave room in grpc: ${ succeed } ` ) ;
218
259
}
219
260
}
220
261
}
0 commit comments