File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,6 @@ export default class KnifeSwitch extends MatchEventProcessor<void> {
3535 } ,
3636 } ) ;
3737
38- await this . matchAssistant . sendServerMatchId ( this . matchId ) ;
38+ await this . matchAssistant . knifeSwitch ( this . matchId ) ;
3939 }
4040}
Original file line number Diff line number Diff line change @@ -66,6 +66,17 @@ export class MatchAssistantService {
6666 }
6767 }
6868
69+ public async knifeSwitch ( matchId : string ) {
70+ try {
71+ await this . command ( matchId , `api_knife_switch` ) ;
72+ } catch ( error ) {
73+ this . logger . warn (
74+ `[${ matchId } ] unable to send knife switch to the server` ,
75+ error . message ,
76+ ) ;
77+ }
78+ }
79+
6980 public async uploadBackupRound ( matchId : string , round : number ) {
7081 try {
7182 await this . command ( matchId , `upload_backup_round ${ round } ` ) ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { MatchEvents } from "./events";
1111import MatchEventProcessor from "./events/abstracts/MatchEventProcessor" ;
1212import { Logger } from "@nestjs/common" ;
1313import { HasuraService } from "src/hasura/hasura.service" ;
14+ import { CacheService } from "src/cache/cache.service" ;
1415
1516export type FiveStackGameServerWebSocketClient = WebSocket . WebSocket & {
1617 id : string ;
@@ -25,6 +26,7 @@ export class MatchEventsGateway {
2526 private readonly logger : Logger ,
2627 private readonly moduleRef : ModuleRef ,
2728 private readonly hasura : HasuraService ,
29+ private readonly cache : CacheService ,
2830 ) { }
2931
3032 async handleConnection (
@@ -78,6 +80,13 @@ export class MatchEventsGateway {
7880 @ConnectedSocket ( ) client : WebSocket . WebSocket ,
7981 ) {
8082 const { matchId, messageId } = message ;
83+
84+ if ( await this . cache . has ( `match-event-${ matchId } -${ messageId } ` ) ) {
85+ return messageId ;
86+ }
87+
88+ await this . cache . put ( `${ matchId } -${ messageId } ` , true , 10 ) ;
89+
8190 const { data, event } = message . data ;
8291
8392 const Processor = MatchEvents [ event as keyof typeof MatchEvents ] ;
You can’t perform that action at this time.
0 commit comments