diff --git a/lib/x11/xcore.js b/lib/x11/xcore.js index c8639bb..8cbef2b 100644 --- a/lib/x11/xcore.js +++ b/lib/x11/xcore.js @@ -1,12 +1,3 @@ -if (process.platform == 'darwin') { - // some strage dns related errors in core node libs on OSX (node v0.6.5) - // skip them at the moment - process.on('uncaughtException', function (err) { - console.log(err); - console.log('Caught exception: ' + err); - }); -} - var util = require('util'); // util.inherits var net = require('net'); @@ -50,7 +41,7 @@ function XClient(stream, displayNum, screenNum) // flushed to stream as result of call to .flush // TODO: listen for drain event and flush automatically //pack_stream.pipe(stream); - + var client = this; pack_stream.on('data', function( data ) { //console.error(hexy(data, {prefix: 'from packer '})); //for (var i=0; i < data.length; ++i) @@ -61,7 +52,10 @@ function XClient(stream, displayNum, screenNum) //console.error(hexy(data, {prefix: 'to unpacker '})); //for (var i=0; i < data.length; ++i) // console.log('>>> ' + data[i]); - pack_stream.write(data); + pack_stream.write(data); + }); + stream.on('end', function() { + client.emit('end'); }); this.pack_stream = pack_stream; @@ -315,7 +309,7 @@ XClient.prototype.expectReplyHeader = function() var unpack = handler[0]; var result = unpack( data, opt_data ); var callback = handler[1]; - callback(result); + callback(null, result); // TODO: add multiple replies flag and delete handler only after last reply (eg ListFontsWithInfo) delete client.replies[seq_num]; }