dist/client/lance-gg.js
/**
     * Overloads onData to detect payloads.
     *
     * @api private
     */
Overloads onData to detect payloads.
@api private
Overloads onData to detect payloads . @api private
onData(data) {
      const self = this;
      debug("polling got data %s", data);
      const callback = function(packet, index, total) {
        if ("opening" === self.readyState && packet.type === "open") {
          self.onOpen();
        }
        if ("close" === packet.type) {
          self.onClose();
          return false;
        }
        self.onPacket(packet);
      };
      lib$1.decodePayload(data, this.socket.binaryType).forEach(callback);
      if ("closed" !== this.readyState) {
        this.polling = false;
        this.emit("pollComplete");
        if ("open" === this.readyState) {
          this.poll();
        } else {
          debug('ignoring poll - transport state "%s"', this.readyState);
        }
      }
    }
onData ( data ) { const self = this ; debug ( "polling got data %s" , data ) ; const callback = function ( packet , index , total ) { if ( "opening" === self . readyState && packet . type === "open" ) { self . onOpen ( ) ; } if ( "close" === packet . type ) { self . onClose ( ) ; return false ; } self . onPacket ( packet ) ; } ; lib$1 . decodePayload ( data , this . socket . binaryType ) . forEach ( callback ) ; if ( "closed" !== this . readyState ) { this . polling = false ; this . emit ( "pollComplete" ) ; if ( "open" === this . readyState ) { this . poll ( ) ; } else { debug ( 'ignoring poll - transport state "%s"' , this . readyState ) ; } } }
Overloads onData to detect payloads.
Overloads onData to detect payloads .
// if its the first message we consider the transport open // if its a close packet, we close the ongoing requests // otherwise bypass onData and handle the message // decode payload // if an event did not trigger closing // if we got data we're not polling