1.0.0 • Published 8 years ago

@snek/sse v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

SSE

Easy SSE for http and http2

const sse = require('sse');

require('http').createServer((req, res) => {
  const c = sse(res);
  setInterval(() => {
    c.send('time', Date.now());
  }, 1000);
}).listen(80);

// OR

require('http2').createSecureServer({
  key: ...
  cert: ...
}).on('stream', (stream) => {
  const c = sse(stream);
  setInterval(() => {
    c.send('time', Date.now());
  }, 1000);
}).listen(443);