• Stars
    star
    264
  • Rank 151,511 (Top 4 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Server-Sent Events made easy for node.js

sse.js: a server-sent events implementation for node.js

The HTML5 Server-Sent events specification is introduced "to enable servers to push data to Web pages over HTTP or using dedicated server-push protocols".

The spec can be found here.

Usage

Installing

npm install sse

Basic server

var SSE = require('sse')
  , http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('okay');
});

server.listen(8080, '127.0.0.1', function() {
  var sse = new SSE(server);
  sse.on('connection', function(client) {
    client.send('hi there!');
  });
});

Client code for the above server:

var es = new EventSource("/sse");
es.onmessage = function (event) {
  console.log(event.data);
};

License

(The MIT License)

Copyright (c) 2011 Einar Otto Stangvik <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

heartbleed-tools

OpenSSL Heartbleed (CVE-2014-0160) vulnerability scanner, data miner and RSA key-restore tools.
Python
96
star
2

http-tunnel

node.js web tunnel - to share the localhost stuff you're working on no matter where you are
JavaScript
38
star
3

ws-audio-example

An example showing how to send, receive and play audio data via websockets
JavaScript
31
star
4

GitAzure

Git hook for node.js apps running in Azure
JavaScript
29
star
5

shared-paperjs

A demo showing how easy node.js and a handful libraries make writing a collaboration app on paper.js
JavaScript
23
star
6

shared-particles

JavaScript
23
star
7

options.js

A very light-weight in-code option parsers for node.js.
JavaScript
21
star
8

tinycolor

a to-the-point color module for node
JavaScript
18
star
9

ratelimit

simple rate limiting / bandwidth capping for node.js streams
JavaScript
18
star
10

vulnscrape

xss vulnerability scraper
Ruby
17
star
11

sslrate

Python
13
star
12

RsyncNet

C#
11
star
13

neopipe

Pipe stuff to Neo4j
JavaScript
10
star
14

sse-example

JavaScript
7
star
15

starttls.info

6
star
16

node-irc

node.js IRC client library for fun and no profit, hitting the scene about 10 years too late.
JavaScript
6
star
17

cqrs.js

JavaScript
4
star
18

websocket-benchmark

node websocket benchmark for v8 perf tuning
JavaScript
4
star
19

shellgraph

A simple tool to graph key distribution from stdin
Python
4
star
20

game.2x.io

JavaScript
2
star
21

KinectGestures

Basic Kinect API demo app, featuring upper body interpolation, some basic gestures and sound effects on trigger.
C#
2
star
22

dynobot

JavaScript
2
star
23

proxydev

Proxy tool for rapid web development spiking
JavaScript
1
star
24

statey

statey - the state machine that couldn't
JavaScript
1
star
25

renode

dev utility to (re)start a node script when files are changed
JavaScript
1
star
26

chargame

JavaScript
1
star
27

urlprobe

This is a url prober, to locate misplaced, sensitive files in web applications. Use it responsibly.
Python
1
star
28

trig-paperjs

JavaScript
1
star
29

dynamic-irc-bot

JavaScript
1
star
30

tiny-elastic-cli

A very tiny elasticsearch query cli
Python
1
star