Comments (4)
I tried something nutty like
function connectToSim() {
simConnect = '';
for (var k in require.cache) {
if (k.indexOf('node-simconnect') >= 0) {
if (k.indexOf('index.js') >= 0) {
console.log('uncache', k);
delete require.cache[k];
}
}
}
simConnect = require('node-simconnect');
But it doesn't seem to help. (dump cache and refresh)
So it's damn weird
from node-simconnect.
In some testing, it doesn't seem to affect the refactor branch. (running outside of electron)
But does the main branch (also outside of electron)
But it's stated we shouldn't use it (refactor) in "production" yet, so I'm hesitant to switch over for my app/usage.
Additionally under main, a setInterval'ed
call to
simConnect.requestDataOnSimObjectType(navInfoDefIdOthers, function(data) {
Is yielding no data/planes returned. So it's not just the open
callback that is failing. (standard 10km range, and I'm parked at EGLL/Heathrow, so there's always 100 odd planes in sim)
Edit: Random side thought, I think under MSFS 1.12.13.0
they actually fixed is so on normal close, NodeSimconnect reads a proper quit (well a quit and an error). (And it's probable the error comes from my setInterval'ed call to requestDataOnSimObjectType
And the issue is in the quit/cleanup logic. As prior to 1.12.13.0
I recall we would just get a sincommect error instead of a nice quit.
from node-simconnect.
It seems that modify all "reconnect" to have an explicit close before hand resolves the problem I have observed
So
https://github.com/EvenAR/node-simconnect/blob/master/examples/nodejs/example.js#L5
Becomes
function connectToSim() {
console.log("Trying to connect...")
var success = simConnect.open("MyAppName", function(name, version) {
console.log("\n-----------------------------------------------\nConnected to: " + name + "\nSimConnect version: " + version + "\n-----------------------------------------------");
doStuffWithSimconnect();
}, () => {
console.log("Quit.... :(");
simConnect.close();
setTimeout(() => {
connectToSim();
}, 5000);
}, (exception) => {
console.log("SimConnect exception: " + exception.name + " (" + exception.dwException + ", " + exception.dwSendID + ", " + exception.dwIndex + ", " + exception.cbData + ")");
}, (error) => {
// Happens for example when connection with SimConnect is lost unexpectedly. For crash details: ntstatus.h
console.log("SimConnect error: " + error);
// The connection must be re-opened
simConnect.close();
setTimeout(() => {
connectToSim();
}, 5000);
});
if(!success) {
simConnect.close();
setTimeout(() => {
connectToSim();
}, 5000);
}
}
Instead.
It's proving more reliable in the
- start app
- open sim
- app connects
- close sim (safe quit as apposed to CTD)
- open sim
- app reconnects properly (calls open callback etc) (yay)
scenario
The explicit call to .close()
seems to tidy out whatever "normal quit" buffer/garbage that doesn't get cleaned up.
from node-simconnect.
I understand a workaround was found for the old version and that v3.x handles this better.
from node-simconnect.
Related Issues (20)
- MFS2020 : Aircraft management from node-simconnect HOT 1
- Need example on how to write simulation variables HOT 6
- Bytebuffer format on electron. HOT 6
- Add some code to the README.md to show how to get and set values? HOT 14
- add .once and .off to SimConnectConnection? HOT 1
- "Title" causes a node-simconnect crash HOT 11
- It looks like open() logs a registry key on failure HOT 4
- How to call transmitClientEvent HOT 2
- Write data variables into created ia aircraft not working HOT 1
- Post NZ World Update 11 - FaclityDataRequest issue crashes sim HOT 1
- Having some issues with `unSubscribeToFacilitiesEx1` HOT 10
- Is it possible to read pmdg CDU screen data? HOT 1
- Pressing the cdu buttons. HOT 2
- Not a real issue, just a heck of a lot of appreciation. HOT 2
- Better type safety for `DataRequestId`, `DataDefinitionId`, `ClientDataDefinitionId`, etc
- Implement new input events API
- Implement SimConnect_EnumerateControllers
- Implement data definition filter API
- Busy-loop caused by subscribeToFacilitiesEx1 HOT 3
- Inconsistent increment/decrement when sending input events
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-simconnect.