docs: public void onReceivedPesponse(ResponseHeader header, Response response){
          Packet packet = null;
          updateRecv();
  
          if (header.getXid() == -4) {
              // -4 is the xid for AuthPacket
              if(ErrorCode.AUTHENT_FAILED.equals(header.getErr())) {
                  if(getStatus().isAlive()){
                      setStatus(ConnectionStatus.AUTH_FAILED);
                  }
              }
                  LOGGER.info("Got auth sessionid:0x" + session.id + ", error=" + header.getErr());
              return;
          }
  
          if (header.getXid() == -1) {
              // -1 means watcher notification
              WatcherEvent event = (WatcherEvent) response;
              if(LOGGER.isTraceEnabled()){
                  LOGGER.trace("Got Watcher " + event + " for sessionid 0x" + session.id);
              }
              eventThread.queueWatcherEvent( event );
              return;
          }
  
          if (header.getXid() == -8) {
              // -8 means server notification
              ServerEvent event = (ServerEvent) response;
  
              if(response instanceof CloseSessionEvent){
                  closeSession();
                  return;
              }
  
              if(LOGGER.isTraceEnabled()){
                  LOGGER.trace("Got Server " + event + " for sessionid 0x" + session.id);
              }
              eventThread.queueServerEvent( event );
              return;
          }
  
          if (header.getXid() == -2) {
              // -2 is the xid for pings
              if(LOGGER.isTraceEnabled()){
                  LOGGER.info("Got ping response for sessionid: 0x" + session.id
                          + " after " + (System.currentTimeMillis() - lastPingSentNs) + "ms");
              }
  
              pingResponse.set(header);
              synchronized(pingResponse){
                  pingResponse.notifyAll();
              }
              return;
          }
  
          synchronized(pendingQueue){
              // the XID out of order, we don't close session here.
              // it doesn't mean the data integrate has problem.
              if(pendingQueue.isEmpty()){
                  LOGGER.warn("The request queue is empty, but get packet xid=" + header.getXid());
                  // we don't  close session here.
                  return;
              }
              int recvXid = header.getXid();
              packet = pendingQueue.remove();
  
              if (packet.protoHeader.getXid() != recvXid) {
                  if(LOGGER.isDebugEnabled()){
                      LOGGER.debug("Packet xid out of order, type=" + packet.protoHeader.getType()
                              + ", queuedXid=" + packet.protoHeader.getXid() + ", xid=" + header.getXid());
                  }
  
                  // trim the pendingQueue to the received packet.
                  if(packet.protoHeader.getXid() > recvXid){
                      LOGGER.error("Packet xid out of order, drop the received packet, xid=" + header.getXid());
                      pendingQueue.addLast(packet);
                      packet = null;
                  } else {
                      while(packet.protoHeader.getXid() != recvXid){
                          LOGGER.error("Packet xid out of order, drop the queued packet, type=" + packet.protoHeader.getType()
                                  + ", queuedXid=" + packet.protoHeader.getXid());
                          packet.respHeader.setErr(ErrorCode.CONNECTION_LOSS);
                          finishPacket(packet);
  
                          if(! pendingQueue.isEmpty()){
                              packet = pendingQueue.remove();
                          } else {
                              return ;
                          }
                      }
                  }
              }
          }
  
          PacketLatency.receivePacket(packet);
          packet.respHeader.setXid(header.getXid());
          packet.respHeader.setErr(header.getErr());
          packet.respHeader.setDxid(header.getDxid());
          if (header.getDxid() > 0) {
              lastDxid = header.getDxid();
          }
          if (ErrorCode.OK.equals(header.getErr())) {
              packet.response = response;
          }
  
          if (LOGGER.isTraceEnabled()) {
              LOGGER.trace("Reading reply sessionid:0x"
                      + session.id + ", packet=" + packet);
          }
          finishPacket(packet);
  
      }