Skip to content

tcavenezuela/simconnect.js

Repository files navigation

simconnect.js

npm version ts release

SimConnect client implementation for NodeJS.

Packages

Quick start

Installation

yarn install simconnect.js

Refer to the package documentation for details on SimConnect APIs and usage and the official SimConnect documentation.

import { open, Protocol } from 'simconnect.js';

const EVENT_ID_PAUSE = 1;

open('My SimConnect client', Protocol.FSX_SP2)
    .then(function ({ recvOpen, handle }) {
        console.log('Connected to', recvOpen.applicationName);

        handle.on('event', function (recvEvent) {
            switch (recvEvent.clientEventId) {
                case EVENT_ID_PAUSE:
                    console.log(recvEvent.data === 1 ? 'Sim paused' : 'Sim unpaused');
                    break;
            }
        });
        handle.on('exception', function (recvException) {
            console.log(recvException);
        });
        handle.on('quit', function () {
            console.log('Simulator quit');
        });
        handle.on('close', function () {
            console.log('Connection closed unexpectedly (simulator CTD?)');
        });

        handle.subscribeToSystemEvent(EVENT_ID_PAUSE, 'Pause');
    })
    .catch(function (error) {
        console.log('Connection failed:', error);
    });

Motivation

I found on the internet several libraries made by simmers and i found that there are several very good libraries but everything was scattered between different repositories. With this package I wanted to mix the best of the community with a monorepo, so we can have the best possible library 🥳.

simconnect.js is based on the following repositories:

Special thanks ✨ to these repositories and their creators, without them simconnect.js would not be possible. 🚀🥳

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you want contribute, follow contribution guidelines here: Contribution Guideline.

License

Distributed under the MIT License. See LICENSE for more information.