Permalink
Browse files

detects and handles when the client tells the server it is closing th…

…e socket.
  • Loading branch information...
1 parent dfac030 commit 72ad2108af0621400d33251261d693d0a3cd7591 @cthayer cthayer committed Mar 23, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/ws/connection.js
View
@@ -92,6 +92,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);
@@ -431,6 +436,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");
+ }
}
}
};

0 comments on commit 72ad210

Please sign in to comment.