public static new OkPacket Parse(PacketReader packetReader) { return(new OkPacket() { FieldCount = packetReader.ReadByte(), AffectedRows = packetReader.ReadLength(), InsertId = packetReader.ReadLength(), ServerStatus = packetReader.ReadShort(), Message = packetReader.ReadString(), }); }
IEnumerable <bool> ProcessRequest(byte packetNumber, byte[] packet) { var queryCommand = commands.Peek().Callback; packetReader.NewPacket(packet); var type = ResponsePacket.GetType(packet); if (type != ResponsePacketType.Other) { var responsePacket = ResponsePacket.Parse(packetReader); queryCommand.FireResponse(responsePacket); FireNextCommand(); yield return(true); yield break; } long length = packetReader.ReadLength(); byte[] data; byte num; FieldPacket[] fields = new FieldPacket[length]; for (int i = 0; i < length; i++) { while (!ReadPacket(out num, out data)) { yield return(false); } packetReader.NewPacket(data); var field = FieldPacket.Parse(packetReader); fields[i] = field; } var f = new Fields(fields); while (!ReadPacket(out num, out data)) { yield return(false); } queryCommand.FireFields(f.FieldPackets); packetReader.NewPacket(data); // TODO: check if the packet is in place EOFPacket.Parse(packetReader); while (true) { while (!ReadPacket(out num, out data)) { yield return(false); } if (ResponsePacket.GetType(data) == ResponsePacketType.EOF) { queryCommand.FireEnd(); FireNextCommand(); yield return(true); yield break; } packetReader.NewPacket(data); string[] values = new string[length]; for (int i = 0; i < length; i++) { values[i] = packetReader.ReadLengthString(); } queryCommand.FireRow(new Row(f, values)); } }
public static new OkPacket Parse(PacketReader packetReader) { return new OkPacket() { FieldCount = packetReader.ReadByte(), AffectedRows = packetReader.ReadLength(), InsertId = packetReader.ReadLength(), ServerStatus = packetReader.ReadShort(), Message = packetReader.ReadString(), }; }