A Twitch.tv viewer reward and games system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

12 years ago
  1. module.exports = ClientAuthenticationPacket;
  2. function ClientAuthenticationPacket(options) {
  3. options = options || {};
  4. this.clientFlags = options.clientFlags;
  5. this.maxPacketSize = options.maxPacketSize;
  6. this.charsetNumber = options.charsetNumber;
  7. this.filler = undefined;
  8. this.user = options.user;
  9. this.scrambleBuff = options.scrambleBuff;
  10. this.database = options.database;
  11. }
  12. ClientAuthenticationPacket.prototype.parse = function(parser) {
  13. this.clientFlags = parser.parseUnsignedNumber(4);
  14. this.maxPacketSize = parser.parseUnsignedNumber(4);
  15. this.charsetNumber = parser.parseUnsignedNumber(1);
  16. this.filler = parser.parseFiller(23);
  17. this.user = parser.parseNullTerminatedString();
  18. this.scrambleBuff = parser.parseLengthCodedBuffer();
  19. this.database = parser.parseNullTerminatedString();
  20. };
  21. ClientAuthenticationPacket.prototype.write = function(writer) {
  22. writer.writeUnsignedNumber(4, this.clientFlags);
  23. writer.writeUnsignedNumber(4, this.maxPacketSize);
  24. writer.writeUnsignedNumber(1, this.charsetNumber);
  25. writer.writeFiller(23);
  26. writer.writeNullTerminatedString(this.user);
  27. writer.writeLengthCodedBuffer(this.scrambleBuff);
  28. writer.writeNullTerminatedString(this.database);
  29. };