@@ -232,7 +232,7 @@ export class MatchGateway implements OnGatewayInit {
232
232
}
233
233
234
234
// Notify both users when they both accept the match
235
- notifyUsersMatchConfirmed ( matchId : string , users : string [ ] ) {
235
+ private notifyUsersMatchConfirmed ( matchId : string , users : string [ ] ) {
236
236
const sessionId = this . generateSessionId ( ) ;
237
237
users . forEach ( ( user ) => {
238
238
const socketId = this . getUserSocketId ( user ) ;
@@ -266,7 +266,7 @@ export class MatchGateway implements OnGatewayInit {
266
266
} ) ;
267
267
}
268
268
269
- notifyUsersWithTimeout ( timedOutUsers : string [ ] ) {
269
+ private notifyUsersWithTimeout ( timedOutUsers : string [ ] ) {
270
270
timedOutUsers . forEach ( ( user ) => {
271
271
const socketId = this . getUserSocketId ( user ) ;
272
272
if ( socketId ) {
@@ -344,6 +344,22 @@ export class MatchGateway implements OnGatewayInit {
344
344
console . log ( `No match cancelled: ${ result . message } ` ) ;
345
345
}
346
346
347
+ // Remove user from matchParticipants and matchConfirmations
348
+ let matchIdToRemove : string | null = null ;
349
+
350
+ this . matchParticipants . forEach ( ( participants , matchId ) => {
351
+ if ( participants . has ( userId ) ) {
352
+ this . notifyOtherUserMatchDeclined ( matchId , userId ) ;
353
+ matchIdToRemove = matchId ;
354
+ }
355
+ } ) ;
356
+
357
+ if ( matchIdToRemove ) {
358
+ this . matchParticipants . delete ( matchIdToRemove ) ;
359
+ this . matchConfirmations . delete ( matchIdToRemove ) ;
360
+ }
361
+
362
+ // Remove user from userSockets
347
363
this . userSockets . delete ( userId ) ;
348
364
console . log ( `User ${ userId } disconnected and removed from userSockets.` ) ;
349
365
} catch ( error ) {
0 commit comments