diff --git a/lib/ws/connection.js b/lib/ws/connection.js index 09a3962..e812304 100644 --- a/lib/ws/connection.js +++ b/lib/ws/connection.js @@ -96,6 +96,11 @@ function Connection(manager, options, req, socket, upgradeHead) { debug(connection.id, 'recv: ' + message); connection.emit('message', message); }); + + parser.on("close", function() { + debug(connection.id, "requested close"); + connection.close(); + }); socket.on('data', function(data) { parser.write(data); @@ -419,6 +424,10 @@ Parser.prototype.write = function(data) { } else if (this.order == 1) { debug('High Order packet handling is not yet implemented.'); this.order = 0; + + if(data[i] === 0x00){ + this.emit("close"); + } } } };