This library provides an easy way to send events to a web browser (or any other client) over HTTP.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Martin Dørum 63000d45ec version bumb 2 years ago
README.md added 'connected' event 5 years ago
client.js $error event, maybe more robust 2 years ago
index.js improved error handling 5 years ago
package.json version bumb 2 years ago
test.js more robust maybe 2 years ago

README.md

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!
});