Socket
Book a DemoInstallSign in
Socket

websocket-multiplexer

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
Package was removed
Sorry, it seems this package was removed from the registry

websocket-multiplexer

Multiple virtual channels over a web socket / SockJS connection

unpublished
latest
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

Websocket multiplexer

Websocket multiplexer, emulates virtual channels over web socket or SockJS.

Its different to the SockJS multiplexer in some ways:

  • Client / Server agnostic.
  • Anonymous channels.
  • Open new channels at any time. No need to specify them ahead.
  • CommonJS, use it with component, browserify or as node.js module.

Installation

component install manuelstofer/websocket-multiplexer
npm install websocket-multiplexer
var Multiplexer = require('websocket-multiplexer');

API

With named channels:

var multiplexer = new Multiplexer({ socket: websocket }),
    example = multiplexer.channel('example');

example.addEventListener('message', function (evt) {
    console.log(evt.data);
});

example.addEventListener('close', function (evt) {

});

Create anonymous channels:

var multiplexer = new Multiplexer({ socket: websocket }),
    channel = multiplexer.channel();

channel.send('hello');

Listen for anonymous channels:

var multiplexer = new Multiplexer({ socket: websocket });

multiplexer.addEventListener('channel', function (evt) {
    var channel = evt.channel;

    channel.addEventListener('message', function (evt) {
        console.log(evt.data);
    });
});

There are also some examples for node.js + ws in examples/ws

Multiplexer

interface Multiplexer {
  attribute Function onchannel;

  // create a channel
  void channel(optional String channel_id);
  void close();
};
Multiplexer implements EventTarget;

Channel

interface Channel {
  attribute String name;
  attribute Function onmessage;
  attribute Function onclose;
  void send(in DOMString data);
  void close();
};
Channel implements EventTarget;

Keywords

websocket

FAQs

Package last updated on 23 Mar 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