Share-Primus
Share-Primus is a client (browser side) extension to ShareJS that lets you use ShareJS with WebSockets, BrowserChannel, SockJS or any other streaming library supported by Primus.
Primus also has several useful plugins such as Substream, which makes it possible to use the same connection as a transport for several logical streams.
Browser
Import the scripts:
Create a connection and subscribe to a document:
var primus = ; var sjs = primus;var doc = sjs;doc; doc;
Server (Node.js)
var primus = server;var shareClient = shareserver; primus;
Run Example
Start the server:
node example/server.js --transformer=websockets
You can also start the server with other streaming frameworks:
node example/server.js --transformer=[websockets|browserchannel|sockjs|engine.io|socket.io]
IMPORTANT! When you start the server the first time, Primus will tell you to npm install
the underlying streaming framework first. Pay close attention to the error message.
The example code is a little more sophisticated than the code above. It also sets up a substream for sending non-sharejs messages over the same connection.
Open a browser: http://localhost:7008/