Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msfs-simconnect-api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msfs-simconnect-api-wrapper - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

v2.2.0
- added an `autoReconnect` property to the `connect()` options. When `true`, this will try to automatically reconnect to MSFS if it happens to disappear/disconnect at any point. Note that this _will_ retrigger `onConnect`.
v2.1.1

@@ -2,0 +6,0 @@

19

msfs-api.js

@@ -20,3 +20,3 @@ import {

const NOT_CONNECTED = `Not connected to MSFS`;
export const MSFS_NOT_CONNECTED = `Not connected to MSFS`;
const SIMCONNECT_FACILITY_LIST_TYPE_AIRPORT = 0;

@@ -54,4 +54,5 @@ const SIMCONNECT_FACILITY_AIRPORT = 1000;

async connect(opts = {}) {
opts.autoReconnect ??= false;
opts.retries ??= 0;
opts.retryInterval ??= 0;
opts.retryInterval ??= 2;
opts.onConnect ??= () => {};

@@ -66,2 +67,6 @@ opts.onRetry ??= () => {};

handle.on("event", (event) => this.handleSystemEvent(event));
handle.on("close", () => {
console.log("whoa");
if (opts.autoReconnect) this.connect(opts);
});
handle.on("exception", (e) => console.error(e));

@@ -178,3 +183,3 @@ this.addAirportHandling(handle);

on(eventDefinition, eventHandler) {
if (!this.connected) throw new Error(NOT_CONNECTED);
if (!this.connected) throw new Error(MSFS_NOT_CONNECTED);
if (!eventDefinition) {

@@ -206,3 +211,3 @@ console.error(`on() called without an event definition`);

trigger(triggerName, value = 0) {
if (!this.connected) throw new Error(NOT_CONNECTED);
if (!this.connected) throw new Error(MSFS_NOT_CONNECTED);
const { handle } = this;

@@ -291,3 +296,3 @@ const eventID = this.nextId();

get(...propNames) {
if (!this.connected) throw new Error(NOT_CONNECTED);
if (!this.connected) throw new Error(MSFS_NOT_CONNECTED);
const DATA_ID = this.nextId();

@@ -319,3 +324,3 @@ const REQUEST_ID = DATA_ID;

set(propName, value) {
if (!this.connected) throw new Error(NOT_CONNECTED);
if (!this.connected) throw new Error(MSFS_NOT_CONNECTED);
const { handle } = this;

@@ -356,3 +361,3 @@ propName = propName.replaceAll(`_`, ` `);

schedule(handler, interval, ...propNames) {
if (!this.connected) throw new Error(NOT_CONNECTED);
if (!this.connected) throw new Error(MSFS_NOT_CONNECTED);
let running = true;

@@ -359,0 +364,0 @@ const run = async () => {

{
"name": "msfs-simconnect-api-wrapper",
"version": "2.1.1",
"version": "2.2.0",
"description": "A convenient SimConnect API for playing with Microsoft Flight Simulator 2020",

@@ -11,3 +11,3 @@ "main": "msfs-api.js",

"scripts": {
"test": "node test.js"
"test": "node test/test.js"
},

@@ -14,0 +14,0 @@ "repository": {

@@ -19,4 +19,5 @@ # msfs-simconnect-api-wrapper

{
retries: positive number or Infinity
retryInterval: positive number, representing number of seconds (not milliseconds) between retries,
autoReconnect: true or false (will try to reconnect to MSFS if the connection gets closed), defaults to `false`.
retries: positive number or Infinity, defaults to 0.
retryInterval: positive number, representing number of seconds (not milliseconds) between retries, defaults to 2.
onConnect: callback function with the node-simconnect handle as its only argument.

@@ -23,0 +24,0 @@ onRetry: callback function with (retries left, retry interval) as its two arguments. This triggers _before_ the next attempt is scheduled.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc