EofPacket.js 721 B

12345678910111213141516171819202122232425
  1. module.exports = EofPacket;
  2. function EofPacket(options) {
  3. options = options || {};
  4. this.fieldCount = undefined;
  5. this.warningCount = options.warningCount;
  6. this.serverStatus = options.serverStatus;
  7. this.protocol41 = options.protocol41;
  8. }
  9. EofPacket.prototype.parse = function(parser) {
  10. this.fieldCount = parser.parseUnsignedNumber(1);
  11. if (this.protocol41) {
  12. this.warningCount = parser.parseUnsignedNumber(2);
  13. this.serverStatus = parser.parseUnsignedNumber(2);
  14. }
  15. };
  16. EofPacket.prototype.write = function(writer) {
  17. writer.writeUnsignedNumber(1, 0xfe);
  18. if (this.protocol41) {
  19. writer.writeUnsignedNumber(2, this.warningCount);
  20. writer.writeUnsignedNumber(2, this.serverStatus);
  21. }
  22. };