webevents

1.2.1 • Public • Published

WebEvents

This library provides an easy way to send events to a web browser (or any other client) over HTTP.

Usage

See the test.js file for an example application.

Server

var http = require("http");
var WebEvents = require("webevnts");

var events = WebEvents();

http.createServer(function(req, res) {
    /*
     * Whatever else your app does on each request
     */

    events.handle(req, res);
});

// Emit whatever events you need
events.emit("someevent", { some: "parameters" });

Client

var events = WebEvents();

// Listen to events
events.on("someevent", function(evt) {
    // evt -> { some: "parameters" }
});

// Do something whenever the client connects (or reconnects)
events.on("connection", function() {
    // Connected!
});

Readme

Keywords

none

Package Sidebar

Install

npm i webevents

Weekly Downloads

5

Version

1.2.1

License

ISC

Unpacked Size

5.53 kB

Total Files

5

Last publish

Collaborators

  • mort