JSPM

share-js-stream

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q26847F
  • License MIT

a stream to manage ShareJS <-> WebSocket client communications

Package Exports

  • share-js-stream

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (share-js-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ShareJSStream

ShareJSStream is a stream that can be used to manage communication between a ShareJS client and a ws connection.

It is a basic drop-in implementation of the ShareJS example stream.

Installation

npm install share-js-stream

Usage

When a connection is established on a ws server, create a ShareJS server client and tell it to listen on a ShareJSStream:

var http          = require('http');
var livedb        = require('livedb');
var share         = require('share');
var ShareJSStream = require('share-js-stream');
var WsServer      = require('ws').Server;

http.createServer().listen(process.env.PORT, function onListen() {
  var wsServer = new WsServer({ server: this });
  wsServer.on('connection', onConnection);
});

function onConnection(conn) {
  var stream = new ShareJSStream(conn);
  share.server
    .createClient({ backend: livedb.client(livedb.memory()) })
    .listen(stream);
}