Closed cxreg closed 10 years ago
The patch is pushed at https://github.com/cxreg/node-esl/commit/e705153a0fc00554e83e687fafc4c04f5534342d
Maybe, looks like the docs recommend this being on the user end; which I agree with because you can create multiple domains and may want to specify which to bind callbacks to.
So basically, instead of doing:
conn = new esl.Connection('127.0.0.1', 8021, 'ClueCon', function() {
conn.show('channels', 'xml', function(err, data, raw) {
if(err) { /* handle error */ }
else { /* stuff... */ }
}));
});
You can do:
var d = domain.create();
conn = new esl.Connection('127.0.0.1', 8021, 'ClueCon', function() {
conn.show('channels', 'xml', d.intercept(function(data, raw) {
/* stuff... */
}));
});
d.on('error', function(err) {
// handle error that would've been passed above, but it intercepted and sent here
});
Closing, going to leave these to user-space.
I think it might be nice to bind the callbacks to an api call to the domain which is active at the time of the call. Other libraries such as node_redis have been looking into this kind of thing as well. What do you think about this?
I have a patch that seems to work if you are interested