Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

lrio

1.2.1 • Public • Published

lrio

js-standard-style travis npm downloads

Minimalist websocket broadcast server and browser client

Feature

  • Broadcast messages using a dedicated channel
  • Attach as many websocket server you want without collision
  • Client for browserify
  • Based on WebSocket-Node

Usage

npm install --save lrio

Server side

 
var http   = require('http');
var lrio   = require('lrio');
var server = http.createServer();
 
var A = lrio(server, 'myChannelA');
var B = lrio(server, 'myChannelB');
 
server.listen(8080);
 
// Broadcast message on myChannelA
A.broadcast({my:42})
 
// Broadcast message on myChannelB
B.broadcast({foo:'bar'})
 
// Other events :
A.on('join',  function(client) {})
A.on('leave', function(client) {})
 

Notice that client are WebSocketConnection instances

Client side (using browserify)

 
var lrio   = require('lrio');
 
var A = lrio('myChannelA');
var B = lrio('myChannelB');
 
A.on('message', function(message) { console.log(message) })
B.on('message', function(message) { console.log(message) })
 
// Other events:
A.on('open', function() {})
A.on('close', function() {})
A.on('error', function() {})
 
A.close(); // Close websocket
A.connect(); // Re-connect  (only if closed)
 

License

The MIT license • Novadiscovery

js-standard-style

Install

npm i lrio

DownloadsWeekly Downloads

40

Version

1.2.1

License

none

Last publish

Collaborators

  • avatar