Node.js and socket.io for the notification bar: Am I going the right way?

I am currently coding a fairly standard Apache / PHP / mySQL site using Symfony2 and considering using Node and socket.io for a special need: a notification bar. Nothing too unusual, a notification is highlighted when you have a new friend request, new mail ...

I do not like too much to periodically query my DB from the ajax cycle; I would like this feature to be fully scalable and have a minimum size.

Thus, I am considering the possibility of submitting a separate periodic request to my database on the server side, submitting my list of open sockets to Node using push notifications for each interested user.

Am I going the right way?

Greetings

+6
source share
1 answer

You are definitely on the right track, but I suggest putting notification materials in your application, rather than querying your database. For example, a friendโ€™s request, do this when a friendโ€™s request is sent:

function send_friend_request($from, $to) { $mysqli->whatever you do with that; send_notification($to, 'You have a friend request!'); } 

where send_notification is a method that sends a POST request to your nodejs server. The nodejs server receives a POST and passes a message to what is listening to $to .

+3
source

Source: https://habr.com/ru/post/950202/


All Articles