mirror of
https://github.com/danbulant/node-x11
synced 2026-05-19 20:39:03 +00:00
connet handler as a parameter to createClient
This commit is contained in:
parent
b1625af9ca
commit
8cf496a220
1 changed files with 20 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue