src/networking/Communication.js
/*
   * Sends all the updated data to the UI. It will send a ping even if no data has been
   * updated. Think of it as a heartbeat.
  */
Sends all the updated data to the UI. It will send a ping even if no data has been
updated. Think of it as a heartbeat.
Sends all the updated data to the UI . It will send a ping even if no data has been updated . Think of it as a heartbeat .
tick() {
    const currentTime = Date.now();
    const sendPing = currentTime >= this.pingTime;
    if (sendPing) {
      const self = this;
      this.pingInstance(this.instance, () => {
        self.currentPing = Date.now() - currentTime;
        self.shouldFlushData = true;
      });
      this.setPingTime();
    }
    if (this.shouldFlushData || sendPing) {
      this.dataBuffer.id = this.id;
      this.dataBuffer.ping = this.currentPing;
      this.shouldFlushData = false;
      this.client.event.emit(`${this.serviceName}/data/${this.instance}`, this.dataBuffer);
      this.dataBuffer.bnum = [];
    }
  }
tick ( ) { const currentTime = Date . now ( ) ; const sendPing = currentTime >= this . pingTime ; if ( sendPing ) { const self = this ; this . pingInstance ( this . instance , ( ) => { self . currentPing = Date . now ( ) - currentTime ; self . shouldFlushData = true ; } ) ; this . setPingTime ( ) ; } if ( this . shouldFlushData || sendPing ) { this . dataBuffer . id = this . id ; this . dataBuffer . ping = this . currentPing ; this . shouldFlushData = false ; this . client . event . emit ( ` ${ this . serviceName } ${ this . instance } ` , this . dataBuffer ) ; this . dataBuffer . bnum = [ ] ; } }
Sends all the updated data to the UI.
Sends all the updated data to the UI .