handleRemoteData (buffer) {
    // Create a new array with the correct type.
    const intArray = new Int16Array(buffer)

    // Get and set the current timestamp.
    const now = Date.now()
    this.lastDataTimestamp = now

    // Calculate the time delta.
    const dataDelta = now - this.lastDataTimestamp

    // If the delta is above a threshold, emit the event once.
    if (dataDelta > 80) {
      if (!this.hasRemoteDelay) {
        this.emit(EVENT.LAG_START)
        this.hasRemoteDelay = true
      }
    } else {
      if (this.hasRemoteDelay) {
        this.emit(EVENT.LAG_END)
        this.hasRemoteDelay = false
      }
    }

    this._touchDataHandler(0, intArray[3] || 0)
    this._pointerDataHandler(
      intArray[0] || 0,
      intArray[1] || 0,
      (intArray[2] || 0) === 1,
      dataDelta
    )
  }
/**
   * Received from the device of GymoteRemote. The message contains the pointer
   * coordinates, touch coordinates and a boolean indicating if the user is
   * clicking.
   *
   * The data is received as Uint8Array, but has been sent as Int16Array. So we
   * take the buffer of the typed array and create a new one with the correct
   * type.
   *
   * @param {ArrayBuffer} data The data from the Remote.
   */
Received from the device of GymoteRemote. The message contains the pointer
coordinates, touch coordinates and a boolean indicating if the user is
clicking.

The data is received as Uint8Array, but has been sent as Int16Array. So we
take the buffer of the typed array and create a new one with the correct
type.

@param {ArrayBuffer} data The data from the Remote.
Received from the device of GymoteRemote . The message contains the pointer coordinates touch coordinates and a boolean indicating if the user is clicking . The data is received as Uint8Array but has been sent as Int16Array . So we take the buffer of the typed array and create a new one with the correct type . @param { ArrayBuffer } data The data from the Remote .
handleRemoteData (buffer) {
    const intArray = new Int16Array(buffer)
    const now = Date.now()
    this.lastDataTimestamp = now
    const dataDelta = now - this.lastDataTimestamp
    if (dataDelta > 80) {
      if (!this.hasRemoteDelay) {
        this.emit(EVENT.LAG_START)
        this.hasRemoteDelay = true
      }
    } else {
      if (this.hasRemoteDelay) {
        this.emit(EVENT.LAG_END)
        this.hasRemoteDelay = false
      }
    }
    this._touchDataHandler(0, intArray[3] || 0)
    this._pointerDataHandler(
      intArray[0] || 0,
      intArray[1] || 0,
      (intArray[2] || 0) === 1,
      dataDelta
    )
  }
handleRemoteData ( buffer ) { const intArray = new Int16Array ( buffer ) const now = Date . now ( ) this . lastDataTimestamp = now const dataDelta = now - this . lastDataTimestamp if ( dataDelta > 80 ) { if ( ! this . hasRemoteDelay ) { this . emit ( EVENT . LAG_START ) this . hasRemoteDelay = true } } else { if ( this . hasRemoteDelay ) { this . emit ( EVENT . LAG_END ) this . hasRemoteDelay = false } } this . _touchDataHandler ( 0 , intArray [ 3 ] || 0 ) this . _pointerDataHandler ( intArray [ 0 ] || 0 , intArray [ 1 ] || 0 , ( intArray [ 2 ] || 0 ) === 1 , dataDelta ) }
Received from the device of GymoteRemote.
Received from the device of GymoteRemote .
// Create a new array with the correct type. // Get and set the current timestamp. // Calculate the time delta. // If the delta is above a threshold, emit the event once.