Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js: Receive events from browser

How do I receive events from the browser in my node.js code? (e.g: I imagine Mixpanel, kissmetrics, etc do something like this?

thanks

like image 421
donald Avatar asked Jul 14 '26 04:07

donald


2 Answers

The same way any other web server receives events from the browser: the browser makes an HTTP request to the URL of your server and the server receives that request. Listening for HTTP requests is the "Hello World" example for node.js.

like image 85
Dan Grossman Avatar answered Jul 20 '26 22:07

Dan Grossman


What you're looking for is http://hummingbirdstats.com/ realtime stats 20 times a second.

You should also checkout socket.io if you haven't. Websockets events are faster than HTTP requests.

like image 34
generalhenry Avatar answered Jul 20 '26 22:07

generalhenry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!