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

router.js bug -for socket.io Sending and getting data (acknowledgements) #7

Closed
Tracked by #34
tosscaster opened this issue Mar 6, 2015 · 2 comments
Closed
Tracked by #34

Comments

@tosscaster
Copy link

tosscaster commented Mar 6, 2015

Router.prototype.middleware = function () {
  var self = this;
  var gen = compose(this.fns);
  return function* router(next) {
    debug('in router middleware');
    if (!self.fns.length) {
      debug('router not exist');
      return yield* next;
    }
    var context = this;
    var socket = this.socket;

    // replace socket.onevent to start the router
    socket._onevent = socket.onevent;
    socket.onevent = function (packet) {
      var args = packet.data || [];
      if (!args.length) {
        debug('event args not exist');
        return socket._onevent(packet);
      }
      // <------ inserted
      if (null != packet.id) {
        debug('attaching ack callback to event');
        args.push(this.ack(packet.id));
      }
      // <------- end

      context.event = args[0];
      context.data = args.slice(1);

      co.wrap(gen).call(context, function (err) {
        if (err) console.error(err.stack);
        //TODO: error
        socket._onevent(packet);
      });
    };

    yield* next;
  };
};
@ariporad ariporad added the bug label Oct 25, 2015
@ariporad ariporad mentioned this issue Oct 25, 2015
9 tasks
@ariporad ariporad added this to the 0.1.0 milestone Oct 25, 2015
@ariporad
Copy link
Contributor

Hi!

I just took over this project, and as part of v0.1.0 (#34), I'd like to be able to solve this bug. Could you be a little more specific about the problem you're having?

Thanks!

@tunnckoCore
Copy link

@ariporad I think this one is absolutely the same as #27 PR. So I'll close this and think for it.

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

3 participants