connet handler as a parameter to createClient

This commit is contained in:
sidorares 2011-07-25 13:50:46 +10:00
parent b1625af9ca
commit 8cf496a220

View file

@ -288,18 +288,26 @@ var platformDefaultTransport = {
// TODO: check process.platform on SmartMachine solaris box
}
module.exports.createClient = function()
module.exports.createClient = function(initCb)
{
// TODO: parse $DISPLAY
// open stream
var stream;
var defaultTransportName = platformDefaultTransport[process.platform];
// use tcp if stated explicitly or if not defined at all
if (!defaultTransportName || defaultTransportName == 'tcp')
stream = net.createConnection(6000);
if (defaultTransportName == 'unix')
stream = net.createConnection('/tmp/.X11-unix/X0');
// TODO: parse $DISPLAY
// open stream
var stream;
var defaultTransportName = platformDefaultTransport[process.platform];
// use tcp if stated explicitly or if not defined at all
if (!defaultTransportName || defaultTransportName == 'tcp')
stream = net.createConnection(6000);
if (defaultTransportName == 'unix')
stream = net.createConnection('/tmp/.X11-unix/X0');
return new XClient(stream);
var client = new XClient(stream);
if (initCb)
{
client.on('connect', function(display) {
display.client = client;
initCb(display);
});
}
return client;
}