@@ -27,14 +27,6 @@ export class SocketsGateway {
2727 private nodeId : string = process . env . POD_NAME ;
2828 private clients : Map < string , FiveStackWebSocketClient > = new Map ( ) ;
2929
30- public static GET_AVAILABLE_NODES_KEY ( ) {
31- return `available-socket-nodes` ;
32- }
33-
34- public static GET_NODE_STATUS_KEY ( nodeId : string ) {
35- return `socket-node:${ nodeId } :status` ;
36- }
37-
3830 public static GET_PLAYER_KEY ( steamId : string ) {
3931 return `players:${ steamId } ` ;
4032 }
@@ -55,6 +47,10 @@ export class SocketsGateway {
5547 return `${ SocketsGateway . GET_PLAYER_CLIENTS_BY_NODE ( steamId , nodeId ) } :${ clientId } ` ;
5648 }
5749
50+ public static GET_PLAYER_CLIENT_LATENCY_TEST ( sessionId : string ) {
51+ return `latency-test:${ sessionId } ` ;
52+ }
53+
5854 constructor (
5955 private readonly logger : Logger ,
6056 private readonly config : ConfigService ,
@@ -90,8 +86,6 @@ export class SocketsGateway {
9086 break ;
9187 }
9288 } ) ;
93-
94- void this . setupNode ( ) ;
9589 }
9690
9791 @SubscribeMessage ( "ping" )
@@ -137,16 +131,19 @@ export class SocketsGateway {
137131
138132 client . id = uuidv4 ( ) ;
139133 client . user = request . user ;
134+ client . sessionId = request . session . id ;
140135 client . node = this . nodeId ;
141136
142137 this . clients . set ( client . id , client ) ;
143138
144139 await this . updateClient ( client . user . steam_id , client . id ) ;
145140
141+ await this . matchmaking . cancelOffline ( client . user . steam_id ) ;
142+
146143 await this . sendPeopleOnline ( ) ;
147144 await this . matchmaking . sendRegionStats ( client . user ) ;
148145 await this . matchmakingLobbyService . sendQueueDetailsToPlayer (
149- client . user ,
146+ client . user . steam_id ,
150147 ) ;
151148
152149 client . on ( "close" , async ( ) => {
@@ -169,24 +166,7 @@ export class SocketsGateway {
169166
170167 await this . sendPeopleOnline ( ) ;
171168
172- // GIVE THEM A DELAY
173- // this.matchMaking.leaveQueue(client);
174-
175- // await this.hasura.mutation({
176- // delete_lobby_players: {
177- // __args: {
178- // where: {
179- // steam_id: {
180- // _eq: client.user.steam_id,
181- // },
182- // status: {
183- // _eq: "Accepted",
184- // },
185- // },
186- // },
187- // __typename: true,
188- // },
189- // });
169+ this . matchmaking . markOffline ( client . user . steam_id ) ;
190170 }
191171 } ) ;
192172 } ) ;
@@ -285,24 +265,4 @@ export class SocketsGateway {
285265
286266 this . clients . delete ( clientId ) ;
287267 }
288-
289- private async setupNode ( ) {
290- await this . redis . sadd (
291- SocketsGateway . GET_AVAILABLE_NODES_KEY ( ) ,
292- this . nodeId ,
293- ) ;
294- const markOnline = async ( ) => {
295- await this . redis . set (
296- SocketsGateway . GET_NODE_STATUS_KEY ( this . nodeId ) ,
297- "true" ,
298- "EX" ,
299- 60 ,
300- ) ;
301- } ;
302-
303- // await markOnline();
304- // setInterval(async () => {
305- // await markOnline();
306- // }, 30 * 1000);
307- }
308268}
0 commit comments