function controlChannelRequest(server, message) {
  var address = message.request.address;
  var req = { headers: {} };

  // handler to call when the connection sequence completes
  var self = server;
  
  if (message.request.method) {
    // we received a GET request or a small POST http request
    // the response should be sent over the control channel
    req = new IncomingMessage(message, server.controlChannel);
    if ( message.request.body == true) {
       self.pendingRequest = req;
    } else {
      req.push(null);
    }

    var res = new ServerResponse(req);
    res.requestId = message.request.id;
    res._controlChannel = server.controlChannel;
    res._rendezvousAddress = address;
    server.emit('request', req, res);
  } else {
    // we received a chunked request or a large (>64kb) request
    // execute the web socket rendezvous with the server
    try {
      var client = new WebSocket(address, {
        perMessageDeflate: false
      });
      client.on('open', function() {
        
        server.emit('requestchannel', client);
        if (self.options.clientTracking) {
          self.clients.push(client);
          ws.on('close', function() {
            var index = self.clients.indexOf(client);
            if (index != -1) {
              self.clients.splice(index, 1);
            }
          });
        }
      });

      client.on('error', function(event) {
        var index = server.clients.indexOf(client);
        if (index != -1) {
          server.clients.splice(index, 1);
        }
      });

    } catch (err) {
      console.log(err);
    }
  }
}
/* 
 * accept a control-channel request
 */
accept a control-channel request
accept a control - channel request
function controlChannelRequest(server, message) {
  var address = message.request.address;
  var req = { headers: {} };
  var self = server;
  if (message.request.method) {
    req = new IncomingMessage(message, server.controlChannel);
    if ( message.request.body == true) {
       self.pendingRequest = req;
    } else {
      req.push(null);
    }
    var res = new ServerResponse(req);
    res.requestId = message.request.id;
    res._controlChannel = server.controlChannel;
    res._rendezvousAddress = address;
    server.emit('request', req, res);
  } else {
    try {
      var client = new WebSocket(address, {
        perMessageDeflate: false
      });
      client.on('open', function() {
        server.emit('requestchannel', client);
        if (self.options.clientTracking) {
          self.clients.push(client);
          ws.on('close', function() {
            var index = self.clients.indexOf(client);
            if (index != -1) {
              self.clients.splice(index, 1);
            }
          });
        }
      });
      client.on('error', function(event) {
        var index = server.clients.indexOf(client);
        if (index != -1) {
          server.clients.splice(index, 1);
        }
      });
    } catch (err) {
      console.log(err);
    }
  }
}
function controlChannelRequest ( server , message ) { var address = message . request . address ; var req = { headers : { } } ; var self = server ; if ( message . request . method ) { req = new IncomingMessage ( message , server . controlChannel ) ; if ( message . request . body == true ) { self . pendingRequest = req ; } else { req . push ( null ) ; } var res = new ServerResponse ( req ) ; res . requestId = message . request . id ; res . _controlChannel = server . controlChannel ; res . _rendezvousAddress = address ; server . emit ( 'request' , req , res ) ; } else { try { var client = new WebSocket ( address , { perMessageDeflate : false } ) ; client . on ( 'open' , function ( ) { server . emit ( 'requestchannel' , client ) ; if ( self . options . clientTracking ) { self . clients . push ( client ) ; ws . on ( 'close' , function ( ) { var index = self . clients . indexOf ( client ) ; if ( index != - 1 ) { self . clients . splice ( index , 1 ) ; } } ) ; } } ) ; client . on ( 'error' , function ( event ) { var index = server . clients . indexOf ( client ) ; if ( index != - 1 ) { server . clients . splice ( index , 1 ) ; } } ) ; } catch ( err ) { console . log ( err ) ; } } }
accept a control-channel request
accept a control - channel request
// handler to call when the connection sequence completes // we received a GET request or a small POST http request // the response should be sent over the control channel // we received a chunked request or a large (>64kb) request // execute the web socket rendezvous with the server