ComChangeUserPacket.js 906 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.user = parser.parseNullTerminatedString();
  12. this.scrambleBuff = parser.parseLengthCodedBuffer();
  13. this.database = parser.parseNullTerminatedString();
  14. this.charsetNumber = parser.parseUnsignedNumber(1);
  15. };
  16. ComChangeUserPacket.prototype.write = function(writer) {
  17. writer.writeUnsignedNumber(1, this.command);
  18. writer.writeNullTerminatedString(this.user);
  19. writer.writeLengthCodedBuffer(this.scrambleBuff);
  20. writer.writeNullTerminatedString(this.database);
  21. writer.writeUnsignedNumber(1, this.charsetNumber);
  22. };