Timer
This commit is contained in:
@@ -7,12 +7,13 @@ const nonNegInt = z.number().int().min(0);
|
||||
|
||||
const createTimer = z.object({
|
||||
name: z.string().min(1).max(200),
|
||||
totalTime: positiveInt,
|
||||
timerMode: z.enum(['group', 'crossfit']).optional(),
|
||||
workoutDate: z.string().optional().nullable(),
|
||||
exerciseCount: positiveInt,
|
||||
setCount: positiveInt,
|
||||
setTime: positiveInt,
|
||||
restTime: nonNegInt.default(0),
|
||||
moveTime: nonNegInt.default(0),
|
||||
setCount: positiveInt,
|
||||
exerciseCount: positiveInt,
|
||||
lapCount: positiveInt.default(1),
|
||||
});
|
||||
|
||||
|
||||
@@ -32,6 +32,19 @@ function init(httpServer) {
|
||||
io.on('connection', (socket) => {
|
||||
logger.debug({ userId: socket.data.user?.id }, 'Socket connected');
|
||||
|
||||
socket.on('timer:join', ({ sessionId } = {}) => {
|
||||
if (!sessionId) return;
|
||||
socket.join(sessionId);
|
||||
// Lazy require avoids load-time circular dependency
|
||||
const timerSvc = require('../modules/timers/service');
|
||||
const engine = timerSvc.getSessionEngine(sessionId);
|
||||
if (engine) socket.emit('timer:state', engine.getState());
|
||||
});
|
||||
|
||||
socket.on('timer:leave', ({ sessionId } = {}) => {
|
||||
if (sessionId) socket.leave(sessionId);
|
||||
});
|
||||
|
||||
socket.on('disconnect', (reason) => {
|
||||
logger.debug({ userId: socket.data.user?.id, reason }, 'Socket disconnected');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user