From c6da7dd7b738c8f3deba2a9e6fa9e9f5e5ee329c Mon Sep 17 00:00:00 2001 From: sidorares Date: Mon, 18 Jul 2011 10:50:26 +1000 Subject: [PATCH] better platform detection --- lib/x11/xcore.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/x11/xcore.js b/lib/x11/xcore.js index 78b1ae4..3c7f5c5 100644 --- a/lib/x11/xcore.js +++ b/lib/x11/xcore.js @@ -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);