Timer
This commit is contained in:
@@ -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