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
Make the engine.io client work in Node.js enviornments that have a window global #147
Comments
What's a proper node.js check? |
I believe that things like |
I was thinking about a |
exports.request = function request (xdomain) {
if ('undefined' !== typeof require && require.extensions && '.node' in require.extensions) {
var _XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return new _XMLHttpRequest();
}
if (xdomain && 'undefined' != typeof XDomainRequest && !exports.ua.hasCORS) {
return new XDomainRequest();
}
// XMLHttpRequest can be disabled on IE
try {
if ('undefined' != typeof XMLHttpRequest && (!xdomain || exports.ua.hasCORS)) {
return new XMLHttpRequest();
}
} catch (e) { }
if (!xdomain) {
try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) { }
}
}; Would work against edge cases of client module loaders. No mode loader is going to require '.node' files and the module system is set in stone in node so it would be save enough to expect this property. |
or we can just forget all the checks.. and add a
|
I like that most I think. Not sure if that exact impl is gonna work though. |
i'll make a pull req with working version :p |
The current
node
check is really awful as it check is a globalwindow
variable is defined or not; https://github.com/LearnBoost/engine.io-client/blob/master/lib/util.js#L204-L226Which happens to be case in my app. Is there a way we can make this a proper node.js check?
The text was updated successfully, but these errors were encountered: