/** * Shared Socket.IO Instance * This module provides a centralized Socket.IO instance that can be shared * across different parts of the application (app.js, handlers, etc.) */ let io = null /** * Set the Socket.IO instance * @param {SocketIO.Server} socketIOInstance - The Socket.IO server instance */ function setSocketIOInstance (socketIOInstance) { io = socketIOInstance } /** * Get the Socket.IO instance * @returns {SocketIO.Server|null} - The Socket.IO server instance or null if not set */ function getSocketIOInstance () { if (!io) { console.warn('⚠️ Socket.IO instance has not been initialized yet') } return io } /** * Check if Socket.IO instance is available * @returns {boolean} - True if instance is available, false otherwise */ function isSocketIOAvailable () { return io !== null } module.exports = { setSocketIOInstance, getSocketIOInstance, isSocketIOAvailable }