File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
backend/gateway-service/src/modules/match Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ export class MatchGateway implements OnGatewayInit {
145
145
}
146
146
147
147
async handleConnection ( @ConnectedSocket ( ) client : Socket ) {
148
- const id = client . handshake . query . userId ;
148
+ const id = client . handshake . query . userId as string ;
149
149
150
150
if ( ! id ) {
151
151
client . emit (
@@ -157,6 +157,17 @@ export class MatchGateway implements OnGatewayInit {
157
157
}
158
158
159
159
try {
160
+ // Check if user is already connected
161
+ const existingSocketId = this . userSockets . get ( id ) ;
162
+ if ( existingSocketId ) {
163
+ client . emit (
164
+ EXCEPTION ,
165
+ 'Error connecting to /match socket: User already connected.' ,
166
+ ) ;
167
+ return ;
168
+ }
169
+
170
+ // Check if valid user exists in database
160
171
const existingUser = await firstValueFrom (
161
172
this . userClient . send ( { cmd : 'get-user-by-id' } , id ) ,
162
173
) ;
You can’t perform that action at this time.
0 commit comments