A TypeScript client library for nodeJs that uses the ExtPlane plugin.
Based on ExtPlaneJs
- You obviously need X-Plane with the ExtPlane plugin installed.
- NodeJs >= 10.18
Install via npm
$ npm install --save @ponjimon/extplane-js
Install via yarn
$ yarn add @ponjimon/extplane-js
const { ExtPlane } = '@ponjimon/extplane-js';
const extPlane = new ExtPlane({
host: '127.0.0.1',
port: 51000,
debug: true,
});
extPlane
.interval(1000)
.observe([
'sim/flightmodel/position/latitude',
'sim/flightmodel/position/longitude',
'sim/time/framerate_period',
])
.subscribe({
next: ([dataRef, value]) => {
switch (dataRef) {
case 'sim/flightmodel/position/latitude':
console.warn('Lat', value);
break;
case 'sim/flightmodel/position/longitude':
console.warn('Long', value);
break;
case 'sim/time/framerate_period':
console.warn('FPS', Math.floor(1 / value));
break;
}
},
});
Instantiates extplane-ts. Does not connect until an observer is added!
Connects to ExtPlane
Disconnects ExtPlane
Connects to ExtPlane (if not already connected) and subscribes to one or more datarefs
Unsubscribes one or more datarefs, but does not close the connection