Skip to content

fstfwd/share-js-stream

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShareJSStream Build Status

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, tell a ShareJS server client to listen on a ShareJSStream:

var ShareJSStream = require('share-js-stream');
var WsServer      = require('ws').Server;
var http          = require('http');
var livedb        = require('livedb');
var shareServer   = require('share').server.createClient({
  backend: livedb.client(livedb.memory()) 
});

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);
  shareServer.listen(stream);
}

Testing

Run tests:

npm test

There is also a sandbox that can be started:

node test/sandbox

This will serve a basic ShareJS app (with an in-memory store) on process.env.PORT or port 5000. Debugging on the ShareJSStream is enabled here, so you'll see verbose logging for stream activity in the console.

About

A stream for ws <-> ShareJS communication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.0%
  • HTML 4.0%