processResponse method
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;
if (_cancelled) {
_streamController.close();
return HandlerResponse(result: null);
}
if (_state == STATE_HEADER_PACKET) {
packet = checkResponse(response);
}
if (packet == null) {
if (response[0] == PACKET_EOF) {
if (_state == STATE_FIELD_PACKETS) {
return _handleEndOfFields();
} else if (_state == STATE_ROW_PACKETS) {
return _handleEndOfRows();
}
} else {
switch (_state) {
case STATE_HEADER_PACKET:
_handleHeaderPacket(response);
break;
case STATE_FIELD_PACKETS:
_handleFieldPacket(response);
break;
case STATE_ROW_PACKETS:
_handleRowPacket(response);
break;
}
}
} else if (packet is OkPacket) {
_okPacket = packet;
if ((packet.serverStatus! & SERVER_MORE_RESULTS_EXISTS) == 0) {
var stream = StreamedResults(_okPacket.insertId, _okPacket.affectedRows, <Field>[]);
_resultsCompleter.complete(stream);
return HandlerResponse(result: stream);
}
}
return HandlerResponse();
}