@@ -2,8 +2,8 @@ import { client, logQueueStatus } from '@/lib/db';
2
2
import { POOL_INDEX , STREAM_GROUP , STREAM_NAME , STREAM_WORKER } from '@/lib/db/constants' ;
3
3
import { decodePoolTicket , getPoolKey , getStreamId } from '@/lib/utils' ;
4
4
import { getMatchItems } from '@/services' ;
5
- import { MATCH_SVC_EVENT } from '@/ws' ;
6
5
import { IMatchType } from '@/types' ;
6
+ import { MATCH_SVC_EVENT } from '@/ws' ;
7
7
8
8
import { connectClient , sendNotif } from './common' ;
9
9
@@ -64,7 +64,6 @@ async function processMatch(
64
64
const matchedStreamId = getStreamId ( timestamp ) ;
65
65
66
66
logger . info ( `Found match: ${ JSON . stringify ( matched ) } ` ) ;
67
-
68
67
69
68
await Promise . all ( [
70
69
// Remove other from pool
@@ -74,9 +73,15 @@ async function processMatch(
74
73
] ) ;
75
74
76
75
// Notify both sockets
77
- const { ...matchItems } = await getMatchItems ( searchIdentifier , topic , difficulty , requestorUserId , matchedUserId ) ;
76
+ const { ...matchItems } = await getMatchItems (
77
+ searchIdentifier ,
78
+ topic ,
79
+ difficulty ,
80
+ requestorUserId ,
81
+ matchedUserId
82
+ ) ;
78
83
logger . info ( `Generated Match - ${ JSON . stringify ( matchItems ) } ` ) ;
79
-
84
+
80
85
sendNotif ( [ requestorSocketPort , matchedSocketPort ] , MATCH_SVC_EVENT . SUCCESS , matchItems ) ;
81
86
sendNotif ( [ requestorSocketPort , matchedSocketPort ] , MATCH_SVC_EVENT . DISCONNECT ) ;
82
87
@@ -91,7 +96,7 @@ async function processMatch(
91
96
92
97
async function match ( ) {
93
98
const redisClient = await connectClient ( client ) ;
94
-
99
+
95
100
const stream = await redisClient . xReadGroup (
96
101
STREAM_GROUP ,
97
102
STREAM_WORKER ,
0 commit comments