dist/client/lance-gg.js
/**
       * Decodes an encoded packet string into packet JSON.
       *
       * @param {String} obj - encoded packet
       */
Decodes an encoded packet string into packet JSON.
@param {String} obj - encoded packet
Decodes an encoded packet string into packet JSON . @param { String } obj - encoded packet
add(obj) {
          let packet;
          if (typeof obj === "string") {
              packet = this.decodeString(obj);
              if (packet.type === PacketType.BINARY_EVENT ||
                  packet.type === PacketType.BINARY_ACK) {
                  this.reconstructor = new BinaryReconstructor(packet);
                  if (packet.attachments === 0) {
                      super.emit("decoded", packet);
                  }
              }
              else {
                  super.emit("decoded", packet);
              }
          }
          else if (isBinary_1.isBinary(obj) || obj.base64) {
              if (!this.reconstructor) {
                  throw new Error("got binary data when not reconstructing a packet");
              }
              else {
                  packet = this.reconstructor.takeBinaryData(obj);
                  if (packet) {
                      this.reconstructor = null;
                      super.emit("decoded", packet);
                  }
              }
          }
          else {
              throw new Error("Unknown type: " + obj);
          }
      }
add ( obj ) { let packet ; if ( typeof obj === "string" ) { packet = this . decodeString ( obj ) ; if ( packet . type === PacketType . BINARY_EVENT || packet . type === PacketType . BINARY_ACK ) { this . reconstructor = new BinaryReconstructor ( packet ) ; if ( packet . attachments === 0 ) { super . emit ( "decoded" , packet ) ; } } else { super . emit ( "decoded" , packet ) ; } } else if ( isBinary_1 . isBinary ( obj ) || obj . base64 ) { if ( ! this . reconstructor ) { throw new Error ( "got binary data when not reconstructing a packet" ) ; } else { packet = this . reconstructor . takeBinaryData ( obj ) ; if ( packet ) { this . reconstructor = null ; super . emit ( "decoded" , packet ) ; } } } else { throw new Error ( "Unknown type: " + obj ) ; } }
Decodes an encoded packet string into packet JSON.
Decodes an encoded packet string into packet JSON .
// binary packet's json // no attachments, labeled binary but no binary data to follow // non-binary full packet // raw binary data // received final buffer