Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created August 3, 2012 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/62f50dc439943f35db03 to your computer and use it in GitHub Desktop.
Save Raynos/62f50dc439943f35db03 to your computer and use it in GitHub Desktop.
var shoe = require("shoe")
, MuxDemux = require("mux-demux")
module.exports = createShoeStream
function createShoeStream(uri) {
var stream = shoe(uri)
, mdm = MuxDemux()
mdm.pipe(stream).pipe(mdm)
return mdm
}
var shoe = require("shoe")
, MuxDemux = require("mux-demux")
module.exports = createShoeConnection
function createShoeConnection(options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
return shoe(options, interceptStream)
function interceptStream(stream) {
var mdm = MuxDemux()
mdm.on("connection", callback)
stream.pipe(mdm).pipe(stream)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment