processResponse method

HandlerResponse processResponse(
  1. ReadBuffer response
)
override

Parses the response containing the response to the command. Returns a HandlerResponse.

The default implementation returns a finished HandlerResponse with a result which is obtained by calling checkResponse.

Implementation

HandlerResponse processResponse(ReadBuffer response) {
  var packet = checkResponse(response, false, _state == stateRowPacket);
  if (packet == null) {
    if (response[0] == PACKET_EOF) {
      if (_state == stateFieldPacket) {
        return _handleEndOfFields();
      } else if (_state == stateRowPacket) {
        return _handleEndOfRows();
      }
    } else {
      switch (_state) {
        case stateHeaderPacket:
          _handleHeaderPacket(response);
          break;
        case stateFieldPacket:
          _handleFieldPacket(response);
          break;
        case stateRowPacket:
          _handleRowPacket(response);
          break;
      }
    }
  } else if (packet is OkPacket) {
    return _handleOkPacket(packet);
  }
  return HandlerResponse();
}