You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use this package socket.io for real-time notifications
Setup socket server on the backend
Setup client connection (should connect if the user is authed - see code below)
We also want an object to keep track of which users are currently connected - using a service, a database like Redis, or we can for now just use an in-memory variable (not recommended for the future, but it works for this project)
const cache = {}; (works for single instance)
io.on('connect', (socket)=>{
socket.headers.cookies[''] // can do some validation here
socket.disconnect()
})
The text was updated successfully, but these errors were encountered:
io.on('connect', (socket)=>{
socket.headers.cookies[''] // can do some validation here
socket.disconnect()
})
The text was updated successfully, but these errors were encountered: