router.js bug -for socket.io Sending and getting data (acknowledgements)
tosscaster opened this issue · comments
tosscaster commented
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;
};
};
Ari Porad commented
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!
Charlike Mike Reagent commented