Pomax / msfs-simconnect-api-wrapper

A JavaScripty wrapper around node-simconnect
Other
14 stars 6 forks source link

redo the airport code #24

Closed Pomax closed 10 months ago

Pomax commented 11 months ago

For some reason the airport handling is all kinds of broken, where "written as its own script" it will find all airports:

import { Protocol, open } from "node-simconnect";

const { handle } = await open(`airport test`, Protocol.KittyHawk);

const AIRPORT_TYPE = 0;
const list = [];
const requestId = 1;
await new Promise((resolve) => {
  const handler = (data) => {
    if (data.requestID === requestId) {
      const { airports, entryNumber, outOf } = data;
      list.push(...airports);
      if (entryNumber >= outOf -1) {
        handle.off("airportList", handler);
        resolve();
      }
    }
  };
  handle.on("airportList", handler);
  handle.requestFacilitiesList(AIRPORT_TYPE, requestId);
});

console.log(`found ${list.length} airports`);
handle.close();

However, the same code used in the airports.js file stops receiving result sets after the first two.

Pomax commented 10 months ago

safe to say this got addressed with the new airport code.