final POC
This commit is contained in:
@@ -49,7 +49,8 @@ export class JoinGameCommandHandler {
|
||||
}
|
||||
|
||||
// Generate player ID for public games or use provided one
|
||||
const actualPlayerId = command.playerId || uuidv4();
|
||||
// For anonymous players (no playerId), use playerName as the identifier to allow rejoining
|
||||
const actualPlayerId = command.playerId || `guest_${command.playerName}`;
|
||||
|
||||
// Validate game joinability (authentication/org checks done in router)
|
||||
this.validateGameJoinability(game, actualPlayerId, command);
|
||||
@@ -122,7 +123,7 @@ export class JoinGameCommandHandler {
|
||||
|
||||
private async updateGameInRedis(game: GameAggregate, command: JoinGameCommand & { playerId: string }): Promise<void> {
|
||||
try {
|
||||
const redisKey = `game:${game.id}`;
|
||||
const redisKey = `game:${game.gamecode}`;
|
||||
|
||||
// Get existing game data from Redis or create new
|
||||
let gameData: ActiveGameData;
|
||||
@@ -189,9 +190,9 @@ export class JoinGameCommandHandler {
|
||||
}
|
||||
}
|
||||
|
||||
async getGameFromRedis(gameId: string): Promise<ActiveGameData | null> {
|
||||
async getGameFromRedis(gameCode: string): Promise<ActiveGameData | null> {
|
||||
try {
|
||||
const redisKey = `game:${gameId}`;
|
||||
const redisKey = `game:${gameCode}`;
|
||||
const data = await this.redisService.get(redisKey);
|
||||
return data ? JSON.parse(data) as ActiveGameData : null;
|
||||
} catch (error) {
|
||||
@@ -200,9 +201,9 @@ export class JoinGameCommandHandler {
|
||||
}
|
||||
}
|
||||
|
||||
async removePlayerFromRedis(gameId: string, playerId: string): Promise<void> {
|
||||
async removePlayerFromRedis(gameCode: string, playerId: string): Promise<void> {
|
||||
try {
|
||||
const redisKey = `game:${gameId}`;
|
||||
const redisKey = `game:${gameCode}`;
|
||||
const existingData = await this.redisService.get(redisKey);
|
||||
|
||||
if (existingData) {
|
||||
|
||||
Reference in New Issue
Block a user