Disclaimers
I'm looking at implementing a Google Plus, Facebook, StackOverflow style notification system. I'm not an inexperienced developer, and eventually I will figure this out, but I'm just looking for a thrust to the right direction.
What I want is for users who are browsing my site to be notified during their browsing session when they receive a new message.
Currently, all of my messages are stored in a single table.
| id | messageSubject | messageBody | hasRead | readDate | sentDate | sentToUser | sentFromUser |
| 1 | HelloWorld | Nada | 0 | `null` | `null | 1 | 10 |
Now, all of my messages are retrieved from dozens of different sources.
What I want is to have a way to be able to notify users when a new message is received. I'm happy to refactor my code any way which makes it possible to notify my node.js when I receive a insert a message if that is what I need to do.
But I am just not quite sure where to start.
My problem is that all of my messages are entered into mysql through dozens of different sources, my Insert
statements are in a lot of areas. So I just don't know the best way to proceed.
Thanks.
In that event we are sending or emit event 'recieveNotifications' to specific user by using io.to() here we can use either io.to or io.in both are same, we just need to pass the group or channel name here. If you want to send the notification to every user then use socket. broadcast. emit('eventName', data);
You can use socket.io rooms. From the client side emit an event ("join" in this case, can be anything) with any unique identifier (email, id). Server Side: io.sockets.in('[email protected]').
This is an organization based application. In this app, I have to implement chat functionality. So as we all know Socket.io is the best solution for instant messaging app and its reliability.
Try to look at presentation Why databases suck for messaging which is namely about why you shouldn't use databases such as MySQL for messaging. Messaging and notifications systems works well with Event Driven Architecture and I would recommend to watch this presentation or to learn more on this topic from here in order to get a bigger picture about event driven "ecosystem".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With