lib/connection.js
function decoded(err, reply) {
  //console.error('got decoder err %s', err );
  //console.error('got decoder reply %j',reply );
  var res = new Response(this), req, cmd, args;
  if(err) {
    // return decoder errors to the client
    return res.send(err);
  }

  // we should only be handling array request types
  if(!Array.isArray(reply)) {
    return res.send(new Error('bad request, array expected'));
  }else if(!reply.length) {
    return res.send(new Error('bad request, empty array invalid'));
  }

  cmd = reply.shift();

  if(cmd instanceof Buffer) cmd = cmd.toString();

  if(typeof cmd !== 'string') {
    return res.send(new Error('bad request, string command expected'));
  }

  cmd = cmd.toLowerCase();

  // keep track of last command
  this._client.cmd = cmd;

  //console.error('got decoder cmd %s', cmd );
  //console.error('got decoder args %j', reply );

  req = new Request(this, cmd, reply);

  this.emit('command', req, res);
}
function decoded(err, reply) {
  //console.error('got decoder err %s', err );
  //console.error('got decoder reply %j',reply );
  var res = new Response(this), req, cmd, args;
  if(err) {
    // return decoder errors to the client
    return res.send(err);
  }

  // we should only be handling array request types
  if(!Array.isArray(reply)) {
    return res.send(new Error('bad request, array expected'));
  }else if(!reply.length) {
    return res.send(new Error('bad request, empty array invalid'));
  }

  cmd = reply.shift();

  if(cmd instanceof Buffer) cmd = cmd.toString();

  if(typeof cmd !== 'string') {
    return res.send(new Error('bad request, string command expected'));
  }

  cmd = cmd.toLowerCase();

  // keep track of last command
  this._client.cmd = cmd;

  //console.error('got decoder cmd %s', cmd );
  //console.error('got decoder args %j', reply );

  req = new Request(this, cmd, reply);

  this.emit('command', req, res);
}
function decoded ( err , reply ) { //console.error('got decoder err %s', err ); //console.error('got decoder reply %j',reply ); var res = new Response ( this ) , req , cmd , args ; if ( err ) { // return decoder errors to the client return res . send ( err ) ; } // we should only be handling array request types if ( ! Array . isArray ( reply ) ) { return res . send ( new Error ( 'bad request, array expected' ) ) ; } else if ( ! reply . length ) { return res . send ( new Error ( 'bad request, empty array invalid' ) ) ; } cmd = reply . shift ( ) ; if ( cmd instanceof Buffer ) cmd = cmd . toString ( ) ; if ( typeof cmd !== 'string' ) { return res . send ( new Error ( 'bad request, string command expected' ) ) ; } cmd = cmd . toLowerCase ( ) ; // keep track of last command this . _client . cmd = cmd ; //console.error('got decoder cmd %s', cmd ); //console.error('got decoder args %j', reply ); req = new Request ( this , cmd , reply ) ; this . emit ( 'command' , req , res ) ; }
Handle an incoming decoded RESP message.
Handle an incoming decoded RESP message .