diff --git a/lib/handshake.js b/lib/handshake.js index 9fbb623..254837b 100644 --- a/lib/handshake.js +++ b/lib/handshake.js @@ -90,7 +90,7 @@ function readScreens(bl, display, cbDisplayReady) if (display.screen.length == display.screen_num) { delete display.screen_num; - cbDisplayReady(display); + cbDisplayReady(null, display); return; } else { readScreens(bl, display, cbDisplayReady); diff --git a/lib/xcore.js b/lib/xcore.js index 5c68b1c..519c665 100644 --- a/lib/xcore.js +++ b/lib/xcore.js @@ -531,10 +531,12 @@ XClient.prototype.startHandshake = function() { var client = this; handshake.writeClientHello(this.pack_stream, this.displayNum, this.authHost, this.authFamily); - handshake.readServerHello(this.pack_stream, function(display) + handshake.readServerHello(this.pack_stream, function(err, display) { - // TODO: readServerHello can set error state in display - // emit error in that case + if (err) { + client.emit('error', err); + return; + } client.expectReplyHeader(); client.display = display; display.client = client;