Skip to content

Commit

Permalink
http-proxy: emit websocket:start
Browse files Browse the repository at this point in the history
* routing-proxy: allow listening for websocket:* event
  • Loading branch information
indutny committed Oct 23, 2012
1 parent 1df2b30 commit 5df6e7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/node-http-proxy/http-proxy.js
Expand Up @@ -437,6 +437,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
}
}

self.emit('websocket:start', req, socket, head, this.target);

//
// Helper function for setting appropriate socket values:
// 1. Turn of all bufferings
Expand Down
14 changes: 11 additions & 3 deletions lib/node-http-proxy/routing-proxy.js
Expand Up @@ -111,9 +111,17 @@ RoutingProxy.prototype.add = function (options) {
this.proxies[key].on('webSocketProxyError', this.emit.bind(this, 'webSocketProxyError'));
}

this.proxies[key].on('start', this.emit.bind(this, 'start'));
this.proxies[key].on('forward', this.emit.bind(this, 'forward'));
this.proxies[key].on('end', this.emit.bind(this, 'end'));
[
'start',
'forward',
'end',
'websocket:start',
'websocket:end',
'websocket:incoming',
'websocket:outgoing'
].forEach(function(event) {
this.proxies[key].on(event, this.emit.bind(this, event));
}, this);
};

//
Expand Down

0 comments on commit 5df6e7b

Please sign in to comment.