[api] add close event in ws-incoming.js

This commit is contained in:
Jorge 2014-12-09 06:53:42 +01:00 committed by Jarrett Cruger
parent f92a1b6839
commit 26537866b3

View File

@ -96,6 +96,12 @@ var passes = exports;
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
proxySocket.on('error', onOutgoingError);
// Allow us to listen when the websocket has completed
proxySocket.on('end', function () {
server.emit('close', proxyRes, proxySocket, proxyHead);
});
// The pipe below will end proxySocket if socket closes cleanly, but not
// if it errors (eg, vanishes from the net and starts returning
// EHOSTUNREACH). We need to do that explicitly.