feat: redesign auction engine with redis sot
This commit is contained in:
1 parent
737702d78c
commit
e8bb20d988
75 files changed
+12737
-542
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { Namespace } from 'socket.io';
|
||||
import type { AuctionStateResponse } from './auction.service';
|
||||
import type { MatchSideEffectDelta } from './auction-side-effect.service';
|
||||
|
||||
@Injectable()
|
||||
export class AuctionEventBusService {
|
||||
private auctionNamespace?: Namespace;
|
||||
|
||||
public attachAuctionNamespace(namespace: Namespace): void {
|
||||
this.auctionNamespace = namespace;
|
||||
}
|
||||
|
||||
public broadcastMatchSideEffect(
|
||||
matchId: string,
|
||||
delta: MatchSideEffectDelta,
|
||||
): void {
|
||||
this.auctionNamespace?.to(matchId).emit('match-side-effect', delta);
|
||||
}
|
||||
|
||||
public broadcastState(matchId: string, state: AuctionStateResponse): void {
|
||||
this.auctionNamespace?.to(matchId).emit(
|
||||
'state',
|
||||
JSON.parse(JSON.stringify(state)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user