gcs-backend-server / lib /socketio_instance.js
github-actions[bot]
chore: deploy from GitHub Actions (2026-03-08T13:13:40Z)
d9d886e
Raw History Blame Contribute Delete
926 Bytes
/**
* 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
}