sse-stream
Expose HTML5 Server Sent Events as an installable appliance on Node.JS http
servers; connections are emitted as Writable streams.
var http = fs = through = sse = '/sse' serv moduleexports = serv = http sse sse // client-side code: { var es = '/sse' pre = document closed = false documentbody es { ifclosed return pre window } es es { closed = true }}
API
sse = require('sse-stream')(path | options)
Create a SSE server that emits connection
events on new, successful eventstream connections.
The argument may either be a string path
to listen on (defaults to /sse/
) or an object:
path: '/listen/on/this/path' keepalive: 1000
keepalive
determines the interval time in ms that keepalives will be sent to all connected clients.
sse.on('connection', function(client))
client
is a writable stream representing a client connection (request response pair).
Of note, all data sent through this connection will be stringified before sending due to the event stream spec.
client.retry(integer ms)
Send a "retry" message that lets the client know how many MS to wait until retrying a connection that ended.
license
MIT