Nocturnal Practitioners of Magic
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    easyssepublic

    node-easysse

    Easy Server-Sent Events, sincerely, most definitely

    Demo

    This demo show easysse-client working in tandem with node-easysee

    $ cd node-easysse && npm install && npm run-script example
     
    > easysse@0.0.0 example /Users/dnukem/code/easysse
    > node ./example
     
    listening on http://0.0.0.0:65428

    Open a couple browser tabs at the binding address and click the button. Each tab will be synchronized with one another.

    Usage

    Currently easysse is configured as an express middleware

    var require("easysse");
    app.get("/chat-stream", easysse);
     
    app.post("/chat", function(req, res) {
      easysse.emit("chat", req.body.username, req.body.message);
    });

    Using easysse-client

    <script src="easysse-client.js"></script>
    <script>
      var client = easysseClient.connect("/chat-stream");
      client.on("chat", function(username, message){
        console.log(username, "says", message);
      });
     
      $.post("/chat", {username: "mjackson", message: "hehe"});
      // "mjackson says hehe" 
    </script> 

    API

    • easysse — is an express middleware with two parameters (req and res)

    • easysse.emit(eventType[, arg1, ..., argN]) — emit an event to all connected clients

    Compatibility

    Tested on Chrome 33 Please submit any other compatibility reports

    License

    © 2014 nkitsune, mosdef.biz easysse may be freely distributed under the BSD license. For all details and documentation: https://github.com/mosdefbiz/easysse

    Keywords

    install

    npm i easysse

    Downloadslast 7 days

    1

    version

    0.9.0

    license

    BSD

    repository

    github.com

    last publish

    collaborators

    • avatar