Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mmis1000/node-comet

a simple comet server to do long polling
https://github.com/mmis1000/node-comet

Last synced: about 2 months ago
JSON representation

a simple comet server to do long polling

Awesome Lists containing this project

README

        

### A comet server with easy use api

```
//server (with express 4.x)
var Comet = require("./lib/comet");
var comet = new Comet(['test']);

router.use('/comet', comet.getMiddleWare());

setInterval(function(){
comet.pushData('test', Date.now());
}, 1000);
```

```
//client (with jQuery)

var path = '/comet/test';

function request () {

$.get(path, function(result) {
var i;
path = result.newPath;
if (result.datas) {
for (i = 0; i < result.datas.length; i++) {
if (result.datas[i].type === "test") {
console.log(new Date(result.datas[i].data));
}
}
}
request ()
});

}
request ()
```