Easily route mdm streams
JavaScript
Switch branches/tags
Nothing to show
Latest commit 30f817b Aug 14, 2012 @Raynos Raynos send a 404 to the client
Permalink
Failed to load latest commit information.
examples/simple demo upgrade Aug 10, 2012
.gitignore first Aug 9, 2012
.travis.yml
LICENCE first Aug 9, 2012
README.md remove travis Aug 9, 2012
index.js send a 404 to the client Aug 14, 2012
package.json send a 404 to the client Aug 14, 2012

README.md

stream-router

Easy router for routing streams

Example Server

var StreamRouter = require("stream-router")
    , streamRouter = StreamRouter()
    , MuxDemux = require("mux-demux")
    , net = require("net")

streamRouter.addRoute("/foo/:name", handleFoo)

net.createServer(handleTcp).listen(8642)

function handleTcp(con) {
    var mdm = MuxDemux({
        error: false
    })

    mdm.on("connection", streamRouter)

    con.pipe(mdm).pipe(con)
}

function handleFoo(stream, params) {
    stream.write(params.name)

    stream.on("data", console.log.bind(console, "server"))
}

Example client

var MuxDemux = require("mux-demux")
    , net = require("net")
    , mdm = MuxDemux({
        error: false
    })
    , con = net.connect(8642)

con.pipe(mdm).pipe(con)

var foo = mdm.createStream("/foo/bar")

foo.on("data", console.log.bind(console, "client"))

foo.write("bar")

Installation

npm install stream-router

Contributors

  • Raynos

MIT Licenced