This commit is contained in:
2026-01-29 02:24:55 -05:00
parent b567fda0ae
commit f262abff16
2 changed files with 22 additions and 3 deletions

View File

@@ -69,20 +69,24 @@ export function getIO() {
export const socketEvents = {
// Emit to specific user
emitToUser(userId, event, data) {
console.log(`🔔 Emitting ${event} to user:${userId}`);
io.to(`user:${userId}`).emit(event, data);
},
// Emit to all users in a challenge
emitToChallenge(challengeId, event, data) {
console.log(`🔔 Emitting ${event} to challenge:${challengeId}`);
io.to(`challenge:${challengeId}`).emit(event, data);
},
// Prediction events
predictionCreated(challengeId, prediction) {
console.log(`📤 Emitting prediction:created for challenge ${challengeId}`, prediction);
this.emitToChallenge(challengeId, 'prediction:created', prediction);
},
predictionValidated(challengeId, prediction) {
console.log(`📤 Emitting prediction:validated for challenge ${challengeId}`, prediction);
this.emitToChallenge(challengeId, 'prediction:validated', prediction);
},