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

channel socket type #91

Open
tj opened this issue Mar 23, 2013 · 0 comments
Open

channel socket type #91

tj opened this issue Mar 23, 2013 · 0 comments
Assignees

Comments

@tj
Copy link
Owner

tj commented Mar 23, 2013

multiplexed streams.

write end:

var axon = require('..');
var fs = require('fs');

var c = axon.socket('channel');

c.bind(3000);

var files = [
  'lib/sockets/channel.js',
  'lib/sockets/pub.js',
  'lib/sockets/sub.js',
  'lib/sockets/pull.js',
  'lib/sockets/push.js'
]

files.forEach(function(file){
  var f = fs.createReadStream(file);
  var s = c.stream();
  f.pipe(s);
});

read end:

var axon = require('..');

var c = axon.socket('channel');

c.connect(3000);

c.on('stream', function(s){
  console.log('stream %s', s.id);

  s.on('data', function(msg){
    console.log('stream %s -> %s', s.id, msg.length);
  });

  s.on('end', function(){
    console.log('stream %s ended', s.id);
  });
});

got part of this going in add/channels, but it would be nice to have it bi-directional, also need to fix the stream implementation plumbing, but we'll have to refactor for 0.10.x with the less shitty stream implementation anyway so no point jumping through hoops right now for the old version

@ghost ghost assigned tj Mar 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant