ComChangeUserPacket.js 960 B

1234567891011121314151617181920212223242526
  1. module.exports = ComChangeUserPacket;
  2. function ComChangeUserPacket(options) {
  3. options = options || {};
  4. this.command = 0x11;
  5. this.user = options.user;
  6. this.scrambleBuff = options.scrambleBuff;
  7. this.database = options.database;
  8. this.charsetNumber = options.charsetNumber;
  9. }
  10. ComChangeUserPacket.prototype.parse = function(parser) {
  11. this.command = parser.parseUnsignedNumber(1);
  12. this.user = parser.parseNullTerminatedString();
  13. this.scrambleBuff = parser.parseLengthCodedBuffer();
  14. this.database = parser.parseNullTerminatedString();
  15. this.charsetNumber = parser.parseUnsignedNumber(1);
  16. };
  17. ComChangeUserPacket.prototype.write = function(writer) {
  18. writer.writeUnsignedNumber(1, this.command);
  19. writer.writeNullTerminatedString(this.user);
  20. writer.writeLengthCodedBuffer(this.scrambleBuff);
  21. writer.writeNullTerminatedString(this.database);
  22. writer.writeUnsignedNumber(2, this.charsetNumber);
  23. };