Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use EventEmitter public API instead of the private _events array

  • Loading branch information...
commit dc593e99723bd65fa57eaf8c22a16729443577e8 1 parent 7f5228a
@christiaan christiaan authored
Showing with 9 additions and 11 deletions.
  1. +9 −11 lib/socket.io/listener.js
View
20 lib/socket.io/listener.js
@@ -27,17 +27,15 @@ Listener = this.Listener = Class({
this.clients = [];
this.clientsIndex = {};
- var listener = (this.server._events['request'] instanceof Array)
- ? this.server._events['request'][0]
- : this.server._events['request'];
- if (listener){
- this.server._events['request'] = function(req, res){
- if (self.check(req, res)) return;
- listener(req, res);
- };
- } else {
- throw new Error('Couldn\'t find the `request` event in the HTTP server.');
- }
+ var listeners = this.server.listeners('request');
+ this.server.removeAllListeners('request');
+
+ this.server.addListener('request', function(req, res){
+ if (self.check(req, res)) return;
+ for (var i = 0; i < listeners.length; i++) {
+ listeners[i].call(this, req, res);
+ }
+ });
this.server.addListener('upgrade', function(req, socket, head){
if (!self.check(req, socket, true)){
Please sign in to comment.
Something went wrong with that request. Please try again.