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.

25 lines
669 B

12 years ago
  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. };