better platform detection

This commit is contained in:
sidorares 2011-07-18 10:50:26 +10:00
parent 265e2b0bed
commit c6da7dd7b7

View file

@ -182,17 +182,26 @@ XClient.prototype.startHandshake = function()
});
}
var platformDefaultTransport = {
win32: 'tcp',
win64: 'tcp',
cygwin: 'tcp',
linux: 'unix'
// TODO: check process.platform on SmartMachine solaris box
}
module.exports.createClient = function()
{
// TODO: parse $DISPLAY
// open stream
// TODO: better platform matching
var platform = process.platform;
var stream;
if (platform == 'cygwin')
var defaultTransportName = platformDefaultTransport[process.platform];
console.error('Cunnecting using ' + defaultTransportName + ' socket');
// use tcp if stated explicitly or if not defined at all
if (!defaultTransportName || defaultTransportName == 'tcp')
stream = net.createConnection(6000);
else
if (defaultTransportName == 'unix')
stream = net.createConnection('/tmp/.X11-unix/X0');
return new XClient(stream);