I'm wanting to build an application where information will be sent one-way over SocketIO periodically once a minute. For example, the message "It is now 15:05:00".
My idea is to put the io.emit fragment in setInterval or use node-cron. However it doesn't work.
cron.schedule('*/1 * * * *', async(io) => { io.emit('server', { data: 'mydata' }); });
If I put that code in .on('connection') it only launches when the client connects. But with 2 clients connecting at different times, the time to receive the notification is also different.
Please help me to solve this problem
Thanks!
I'm wanting to build an application where information will be sent over SocketIO periodically once a minute. For example, the message will send every begin of minutes