pass displayNum to the XClient contructor

This commit is contained in:
sidorares 2011-08-01 16:35:35 +10:00
parent 45bb344e68
commit 24761ec261
2 changed files with 6 additions and 10 deletions

View file

@ -27,26 +27,21 @@ function parseXauth( buf )
};
cookie.type = buf.unpack('n')[0];
offset += 2;
console.log(cookie.type);
// TODO: rewrite following using loop (16bits length + string data)
var addressLen = buf.unpack('n', offset)[0];
offset += 2;
console.log(addressLen);
cookie.address = buf.unpackString(addressLen, offset);
offset += addressLen;
var displayNumLen = buf.unpack('n', offset)[0];
console.log(displayNumLen);
offset += 2;
cookie.display = buf.unpackString(displayNumLen, offset);
offset += displayNumLen;
var authNameLen = buf.unpack('n', offset)[0];
offset += 2;
console.log(authNameLen);
cookie.authName = buf.unpackString(authNameLen, offset);
offset += authNameLen;
var authDataLen = buf.unpack('n', offset)[0];
offset += 2;
console.log(authDataLen);
cookie.authData = buf.unpackString(authDataLen, offset);
offset += authDataLen;
auth.push(cookie);

View file

@ -19,7 +19,7 @@ var xerrors = require('./xerrors');
var coreRequests = require('./corereqs');
var stdatoms = require('./stdatoms');
function XClient(stream)
function XClient(stream, displayNum, screenNum)
{
EventEmitter.call(this);
this.stream = stream;
@ -27,6 +27,10 @@ function XClient(stream)
this.core_requests = {};
this.ext_requests = {};
this.displayNum = displayNum;
this.screenNum = screenNum;
this.authHost = os.hostname();
pack_stream = new PackStream();
// data received from stream is dispached to
@ -329,10 +333,7 @@ module.exports.createClient = function(initCb, display)
if (defaultTransportName == 'unix' && host == '127.0.0.1')
stream = net.createConnection('/tmp/.X11-unix/X' + displayNum);
var client = new XClient(stream);
client.displayNum = displayNum;
client.screenNum = screenNum;
client.authHost = os.hostname();
var client = new XClient(stream, displayNum, screenNum);
if (initCb)
{
client.on('connect', function(display) {