🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

lrio

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lrio

Minimalist websocket broadcast server and client

latest
Source
npmnpm
Version
1.2.1
Version published
Weekly downloads
8
100%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

livereload

FAQs

Package last updated on 29 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts