-
- this.ws.enable('browser client minification');
- this.ws.enable('browser client etag');
- this.ws.set('transports', transports);
- this.ws.set('resource', (global.config.http_base_path || '') + '/transport');
-
- this.ws.of('/kiwi').authorization(authoriseConnection)
- .on('connection', function () {
- newConnection.apply(that, arguments);
+
+ hs.on('error', function (err) {
+ that.emit('error', err);
+ });
+
+ this.ws = new engine.Server();
+
+ hs.on('upgrade', function(req, socket, head){
+ // engine.io can sometimes "loose" the clients remote address. Keep note of it
+ req.meta = {
+ remote_address: req.connection.remoteAddress
+ };
+
+ that.ws.handleUpgrade(req, socket, head);
+ });
+
+ hs.on('request', function(req, res){
+ var base_path = (global.config.http_base_path || ''),
+ transport_url;
+
+ // Trim off any trailing slashes
+ if (base_path.substr(base_path.length - 1) === '/') {
+ base_path = base_path.substr(0, base_path.length - 1);
+ }
+ transport_url = base_path + '/transport';
+
+ Stats.incr('http.request');
+
+ // engine.io can sometimes "loose" the clients remote address. Keep note of it
+ req.meta = {
+ remote_address: req.connection.remoteAddress
+ };
+
+ // If the request is for our transport, pass it onto engine.io
+ if (req.url.toLowerCase().indexOf(transport_url.toLowerCase()) === 0) {
+ that.ws.handleRequest(req, res);
+ } else {
+ http_handler.serve(req, res);