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]; cookie.type = buf.unpack('n')[0];
offset += 2; offset += 2;
console.log(cookie.type);
// TODO: rewrite following using loop (16bits length + string data) // TODO: rewrite following using loop (16bits length + string data)
var addressLen = buf.unpack('n', offset)[0]; var addressLen = buf.unpack('n', offset)[0];
offset += 2; offset += 2;
console.log(addressLen);
cookie.address = buf.unpackString(addressLen, offset); cookie.address = buf.unpackString(addressLen, offset);
offset += addressLen; offset += addressLen;
var displayNumLen = buf.unpack('n', offset)[0]; var displayNumLen = buf.unpack('n', offset)[0];
console.log(displayNumLen);
offset += 2; offset += 2;
cookie.display = buf.unpackString(displayNumLen, offset); cookie.display = buf.unpackString(displayNumLen, offset);
offset += displayNumLen; offset += displayNumLen;
var authNameLen = buf.unpack('n', offset)[0]; var authNameLen = buf.unpack('n', offset)[0];
offset += 2; offset += 2;
console.log(authNameLen);
cookie.authName = buf.unpackString(authNameLen, offset); cookie.authName = buf.unpackString(authNameLen, offset);
offset += authNameLen; offset += authNameLen;
var authDataLen = buf.unpack('n', offset)[0]; var authDataLen = buf.unpack('n', offset)[0];
offset += 2; offset += 2;
console.log(authDataLen);
cookie.authData = buf.unpackString(authDataLen, offset); cookie.authData = buf.unpackString(authDataLen, offset);
offset += authDataLen; offset += authDataLen;
auth.push(cookie); auth.push(cookie);

View file

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