diff --git a/lib/connection.js b/lib/connection.js index 8f31dcc5..c83ee964 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -89,12 +89,13 @@ Connection.prototype.connect = function(port, host) { Connection.prototype.attachListeners = function(stream) { stream.on('data', function(buff) { this.setBuffer(buff); - var msg; - while(msg = this.parseMessage()) { + var msg = this.parseMessage(); + while(msg) { if(this._emitMessage) { this.emit('message', msg); } this.emit(msg.name, msg); + msg = this.parseMessage(); } }.bind(this)); };