Spaces:
Running
Running
| const { SOCKET_EVENTS } = require("./events"); | |
| let ioInstance = null; | |
| const registerSocketServer = (io) => { | |
| ioInstance = io; | |
| }; | |
| const emitAnnouncementUpdated = (payload = {}) => { | |
| if (!ioInstance) return; | |
| ioInstance.of('/').emit(SOCKET_EVENTS.ANNOUNCEMENT_UPDATED, { | |
| action: payload.action || "updated", | |
| id: payload.id || null, | |
| occurredAt: new Date().toISOString(), | |
| }); | |
| }; | |
| module.exports = { | |
| registerSocketServer, | |
| emitAnnouncementUpdated, | |
| }; | |