const whatsappEvents = require('../emitter'); whatsappEvents.on('connection:added', ({ sock, sessionId }) => {}); whatsappEvents.on('connection:removed', ({ sessionId }) => {}); module.exports = () => { const sessions = new Map(); const createSession = (sessionId, ws) => { sessions.set(ws, sessionId); return { sessionId }; }; const getSession = sessionId => { for (const [ws, storedSessionId] of sessions) { if (storedSessionId === sessionId) { return ws; } } return null; }; const removeSession = ws => { sessions.delete(ws); }; return { createSession, getSession, removeSession, sessions, }; };