Spaces:
Paused
Paused
Download lib/socketio_instance.js from Adhyasta/gcs-backend-server: direct link, hf CLI and curl.
- Browser
- Download file 926 Bytes
-
https://huggingface.co/spaces/Adhyasta/gcs-backend-server/resolve/main/lib/socketio_instance.js
- Command line
-
hf download hf://spaces/Adhyasta/gcs-backend-server/lib/socketio_instance.js
-
curl -L -o socketio_instance.js https://huggingface.co/spaces/Adhyasta/gcs-backend-server/resolve/main/lib/socketio_instance.js
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 | |
| } | |