Open stevvooe opened 9 years ago
Would be interesting to use this interface to expose the Simple Framer. The idea behind the simple framer is that it is the minimum protocol to implement multiplexing for this interface. The only additional concept missing is headers, which are needed to build an application on top of the multiplexer.
Have not started drafting it too much but @mcollina and I discussed having something on the Go and JS side so it could easily be used over websockets in the browser.
Basically what I am using in jschan is a stream containing msgpack5 messages. The format of those messages is very simple, the channel/bytestream id
, the data
payload (what should be sent), and an optional parent
field for creating new channels.
You can see it here: https://github.com/GraftJS/jschan/blob/master/lib/stream/channels.js#L21-L34
Originally proposed in https://github.com/docker/libchan/pull/93#issuecomment-75811135, the following is a possible multiplexing interface that would afford some flexibility:
Then, streams, encoders and decoders pull channels off the multiplexed stream. The base
NewMultiplexer
can be a libchan specific framing protocol but other implementations could provideMultiplexers
.Optionally,
io.ReadWriteCloser
could be anet.Conn
, if that makes more sense.