Tooling to use FSUIPC external application interface, with nodeJS.
npm install @flusinerd/msfs-apifsuipc (fsuipc-node) and @fsuipc/api (this package) to work, and so this API, you must have on your machine:
rxjs >= 6.5.0
npm i --save @fsuipc/api
or
yarn add @fsuipc/api
`
API Usage
After import, you can use FsuipcApi to listen to provided values.
$3
`typescript
import { FsuipcApi } from '@fsuipc/api';
`
$3
`typescript
const fsuipcApi = new FsuipcApi(Simulator.FSX);
`
$3
FsuipcApi.init() returns a promise when you are properly connected to FSUIPC stream. In case your flight simulator isn't running, this will throw an error.
$3
FsuipcApi.listen() methods takes 2-3 arguments:
- interval [number]: interval at which values will be polled from FSUIPC stream
- offsetsList [string[]]: a list of string representing offsets you want to subscribe on
- terminateOnError [boolean = true]: if set to true, if any value is errored, you will be disconnected from FSUIPC stream
This method returns a ConvertedOffsetValues observable. You can subscribe to this observable to handle values polled from stream.
$3
`typescript
import { FsuipcApi } from '@fsuipc/api';
const fsuipcApi = new FsuipcApi(Simulator.FSX);
fsuipcApi.init().then(() => {
fsuipcApi.listen(1000, [
'gs',
'altitude',
'comFreq',
'lights',
]).subscribe((result) => {
// Use the result here
console.log(JSON.stringify(result));
});
}).catch((e) =>
console.error(e)
);
``