easysse
v0.9.0
Published
Server Sent Events, sincerely, most definitely
Downloads
2
Readme
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
> [email protected] 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
andres
)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