ResultSetHeaderPacket.js 669 B

1234567891011121314151617181920212223242526
  1. module.exports = ResultSetHeaderPacket;
  2. function ResultSetHeaderPacket(options) {
  3. options = options || {};
  4. this.fieldCount = options.fieldCount;
  5. this.extra = options.extra;
  6. }
  7. ResultSetHeaderPacket.prototype.parse = function(parser) {
  8. this.fieldCount = parser.parseLengthCodedNumber();
  9. if (parser.reachedPacketEnd()) return;
  10. this.extra = (this.fieldCount === null)
  11. ? parser.parsePacketTerminatedString()
  12. : parser.parseLengthCodedNumber();
  13. };
  14. ResultSetHeaderPacket.prototype.write = function(writer) {
  15. writer.writeLengthCodedNumber(this.fieldCount);
  16. if (this.extra !== undefined) {
  17. writer.writeLengthCodedNumber(this.extra);
  18. }
  19. };