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
Meteor.bindEnvironment does not work outside of a Fiber #465
Comments
In what context are you trying to call The idea of |
Here is the context: Meteor.default_server.stream_server.register(function(socket) {
var intervalID = setInterval(function() {
if (socket.meteor_session) {
var connection = {
connectionID: socket.meteor_session.id,
...
};
socket.id = socket.meteor_session.id;
var insertConnection = Meteor.bindEnvironment(function() {
Ethereal.connections.insert(connection);
}, function (e) {
Meteor._debug("Exception from connection register callback:", e);
}); insertConnection();
clearInterval(intervalID);
}
}, 1000);
socket.on('close', function () {
var removeConnection = Meteor.bindEnvironment(function() {
Ethereal.connections.remove({connectionID: socket.id});
}, function (e) {
Meteor._debug("Exception from connection close callback:", e);
}); removeConnection()
});
}); So what you are saying then, is that I need to wrap the function that I am passing to |
try using |
Right, (BTW, |
Thanks, it seems like I had to wrap every layer of callbacks with |
BTW, this is what I ended up doing. Ethereal.connections = new Meteor.Collection("connections");
if (Meteor.isServer) {
Ethereal.connections.remove({});
Meteor.default_server.stream_server.register( Meteor.bindEnvironment( function(socket) {
var intervalID = Meteor.setInterval(function() {
if (socket.meteor_session) {
var connection = {
connectionID: socket.meteor_session.id,
connectionAddress: socket.address,
userID: socket.meteor_session.userId
};
socket.id = socket.meteor_session.id;
Ethereal.connections.insert(connection);
Meteor.clearInterval(intervalID);
}
}, 1000);
socket.on('close', Meteor.bindEnvironment(function () {
Ethereal.connections.remove({connectionID: socket.id});
}, function(e) {
Meteor._debug("Exception from connection close callback:", e);
}));
}, function(e) {
Meteor._debug("Exception from connection registration callback:", e);
}));
} |
Yes, that looks right to me (or as right as you can get before we provide a supported way of hooking into session/sockets like that). |
Hah, glad to know this was useful for somebody :) https://github.com/murilopolese/howmanypeoplearelooking/blob/master/server/main.js |
Additionally, |
Update babel-register to version 6.24.0 🚀
* Fixing `export const function` syntax error `export const function` results in a syntax error. Fixing one example by just dropping it and changing to a default export for the template test helper. * Code review comment-related updates * last change from code review comment
Meteor.bindEnvironment fails to wrap code in a Fiber when there is no current Fiber.
This is the error:
Seems like boundValues should also be set to an empty array if Fiber.current is null.
The text was updated successfully, but these errors were encountered: