EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
socketEvents.js
Go to the documentation of this file.
1// WebSocket event publisher for dashboard realtime updates
2const Redis = require('ioredis');
3const { Server } = require('socket.io');
4
5const redisConfig = require('./config/redis');
6const redis = new Redis(redisConfig);
7const io = new Server(/* your HTTP server here */);
8
9redis.psubscribe('dashboard:events');
10
11redis.on('pmessage', (pattern, channel, message) => {
12 io.emit(channel, JSON.parse(message));
13});
14
15console.log('Socket event publisher running: dashboard gets live updates from Redis.');