Imp
Imp

Reputation: 8609

Streaming with JavaScript

I want to stream real-time data from a server into a JavaScript webpage. For example, if the server receives meteorological data measurements every second, I want to visualize them as a moving graph on the webpage.

Naturally, Ajax can be used for this. However, this is not what the HTTP protocol was built for. It would help to have a faster, more lightweight protocol. Ideally, a persistent TCP connection. Are there any such possibilites in modern browsers, without using additional plugins and applets? Or can this be only done with Flash, Java, etc...?

Upvotes: 1

Views: 316

Answers (2)

MirrorMirror
MirrorMirror

Reputation: 188

Modern browsers support the Websocket implementation, however as David says, in case your browser does not support it, it will fall back to Flash sockets, Ajax, iframe long polling etc. It's a high level wrapper and easy to implement. Server side you will use nodejs and socket.io, check the documentation of socket.io

Upvotes: 1

Ashley Strout
Ashley Strout

Reputation: 6267

I would check out Socket.IO. It tries to make use of WebSockets, but can fall back on standard AJAX.

Upvotes: 1

Related Questions