@fsuipc.js/api
v2.0.4
Published
<img src="https://user-images.githubusercontent.com/8359234/184555256-5e6458a4-6e4c-489b-b1a6-bfe2e6dcd15a.png" alt="fsuipc.js" width="150"/>
Downloads
18
Readme
FSUIPC client implementation for NodeJS.
@fsuipc.js/api
This package allows you to read +800 predefined offsets.
Quick start
- Install
fsuipc.js
and@fsuipc.js/api
:
yarn add fsuipc.js @fsuipc.js/api
- Import the module and create a new object:
import { FsuipcApi } from '@fsuipc.js/api';
const simulator = new FsuipcApi(Simulator.FSX);
3: Use the method init
to request a list of offsets and then, read the value in the promise:
simulator
.init()
.then(() => {
simulator.listen(true, 2000, ['gs', 'altitude', 'comFreq', 'lights']).subscribe((result) => {
console.log(JSON.stringify(result));
});
})
.catch((e) => console.error(e));
Methods:
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.
Listen:
Listen a list of offsets.
listen method 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]: 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.
Close:
Closes a running connection.