Initial commit

This commit is contained in:
Brian McGonagill 2026-03-18 09:02:21 -05:00
commit b3a51a4115
10336 changed files with 2381973 additions and 0 deletions

2
backend/dist/socket/index.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
import { Server } from 'socket.io';
export default function setupSocket(io: Server): Server<import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, any>;

54
backend/dist/socket/index.js vendored Normal file
View file

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = setupSocket;
const index_js_1 = require("../index.js");
function setupSocket(io) {
io.on('connection', (socket) => {
console.log('Client connected:', socket.id);
socket.on('join-game', async (gameId) => {
socket.join(`game:${gameId}`);
console.log(`Socket ${socket.id} joined game:${gameId}`);
});
socket.on('leave-game', (gameId) => {
socket.leave(`game:${gameId}`);
});
socket.on('team-location', async (data) => {
await index_js_1.prisma.team.update({
where: { id: data.teamId },
data: { lat: data.lat, lng: data.lng }
});
io.to(`game:${data.gameId}`).emit('team-location', {
teamId: data.teamId,
lat: data.lat,
lng: data.lng
});
});
socket.on('chat-message', async (data) => {
const chatMessage = await index_js_1.prisma.chatMessage.create({
data: {
gameId: data.gameId,
teamId: data.teamId,
userId: data.userId,
message: data.message
}
});
io.to(`game:${data.gameId}`).emit('chat-message', {
id: chatMessage.id,
teamId: data.teamId,
userId: data.userId,
userName: data.userName,
message: data.message,
sentAt: chatMessage.sentAt
});
});
socket.on('team-advanced', async (data) => {
io.to(`game:${data.gameId}`).emit('team-advanced', {
teamId: data.teamId
});
});
socket.on('disconnect', () => {
console.log('Client disconnected:', socket.id);
});
});
return io;
}