Glue together shoe, reconnect-core, and mux-demux.
server:
var MuxDemuxSocket = require('mux-demux-websocket/server');
var ecstatic = require('ecstatic')(__dirname+'/public');
var http = require('http');
var server = http.createServer(ecstatic);
server.listen(8000);
console.log('listening on :8000');
// return `shoe` instance
var sock = MuxDemuxSocket(function(mdm) {
var stream = mdm.createWriteStream('server');
stream.write('some content');
});
sock.install(server, '/mdm');
client:
var MuxDemuxSocket = require('mux-demux-websocket/client');
// return `reconnect-core` instance
var con = MuxDemuxSocket(function(mdm) {
mdm.on('connection', function(mdmStream) {
mdmStream.on('data', function(data) {
if (mdmStream.meta === 'server') console.log(data);
});
});
});
con.connect('/mdm');