comet-server
A easy use comet api implement.
Last updated 5 years ago by mmis1000 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install comet-server 
SYNC missed versions from official npm registry.

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 ()

Current Tags

  • 0.0.4                                ...           latest (5 years ago)

5 Versions

  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
  • 0.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 2
This Week 2
This Month 2
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |