Reputation: 23747
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
Upvotes: 3
Views: 787
Reputation: 14725
I recommend dnode. Search for dnode on the browser in the README. It's a quick and complete example of making a RPC. In this case the remote function would be an event handler.
It uses socket.io, which supports websockets, flash sockets, and xhr.
Upvotes: 1
Reputation: 17319
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.
Upvotes: 2
Reputation: 39490
You have to send them to your server, via AJAX or some similar method.
Remember, node code runs on the server; the browser runs on the client. The way to get information back and forth from a server to a client running a web browser is an HTTP request.
Upvotes: 1
Reputation: 52372
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.
Upvotes: 3