Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/mmis1000/node-comet
- Owner: mmis1000
- Created: 2015-04-25T05:11:21.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-27T04:41:21.000Z (about 6 years ago)
- Last Synced: 2024-08-08T23:12:41.685Z (6 months ago)
- Language: CoffeeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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 ()
```