Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose .createStream() #73

Open
juliangruber opened this issue Nov 27, 2012 · 7 comments
Open

Expose .createStream() #73

juliangruber opened this issue Nov 27, 2012 · 7 comments

Comments

@juliangruber
Copy link

I want to use axon with secure-peer for super easy security and thus need access to the raw stream. Any plans on doing this?

@gjohnson
Copy link
Collaborator

Probably not, @visionmedia can correct me but exposing the stream (for the use of composing new streams) wouldn't really mesh well with the protocol, really even with the messaging paradigm in general because of the whole <length> + <body>.

@tj
Copy link
Owner

tj commented Nov 29, 2012

I dont recall us even having a .createStream() anywhere

@juliangruber
Copy link
Author

I just wondered if it would be possible. I want to use axon-rcp for auth stuff and thus need encryption, that's my use case...

@gjohnson
Copy link
Collaborator

Yeah, I assumed @juliangruber meant add one to the api. Like mongoose or something, ala:

subSocket.stream().pipe(whatever);

Right?

@juliangruber
Copy link
Author

server:

var rpc = require('axon-rpc')
  , axon = require('axon')
  , rep = axon.socket('rep')
  , net = require('net');

var server = new rpc.Server(rep);

// instead of this: rep.bind(4000);

net.createServer(function (socket) {
  socket.pipe(server.createStream()).pipe(socket)
}).listen(4000)

client:

var rpc = require('axon-rpc')
  , axon = require('axon')
  , req = axon.socket('req')
  , net = require('net');

var client = new rpc.Client(req);
var clientStream = client.createStream();

// with the net module
clientStream.pipe(net.connect(4000)).pipe(clientStream());

// or with dominictarr's reconnect:
reconnect(function (stream) {
  clientStream.pipe(stream).pipe(clientStream)
}).connect(4000)

This way you make it transport agnostic and it will also work in the browser over websockets, or whatevs!

@tj
Copy link
Owner

tj commented Nov 29, 2012

im fine with it as long as:

  • a) we dont overly complicate internals to abstract out accepting socket connections etc
  • b) we dont change the existing default api
  • c) performance is retained

though personally there wouldn't really be many use-cases to use it for anything but regular tcp, not all transports have the same capabilities, via stdin etc would be leaky

@CoderPuppy
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants