boris_atw
boris_atw

Reputation: 243

Update a web page using socket.io when database is updated by another page

I'm starting playing with NodeJS and Socket.IO and I've got a question regarding communication between pages of my application.

I've got a Node JS script (get_new_data) which is periodicaly executed using a cron task. This script will get information through Internet, parse them and write them in a PG Database. This is ok.

I've got a secondary script (show_last_data) using Node/Express/Socket.io that displays the last information of the DB when it is executed. This is also ok, right now.

What I would like now, is that the script show_last_data would be notified when new data are inserted in the database and the corresponding display divs to be updated.

Can get_new_data connect to show_last_data even if it is not the server that produces the page ? Or should I manage this in another way ?

Thanks for help

Upvotes: 0

Views: 1424

Answers (1)

boris_atw
boris_atw

Reputation: 243

I've finally found a way to manage this using socket.io-client. This page was particulary helpful to solve my question : socket.io as a client

Upvotes: 1

Related Questions