Communication between WASM plugin and external application


Are there ways to send data from a WASM module to an external application is some way?

Something like UDP/TCP sockets or websockets would be great, but as fas as I know they are not supported.


I think the only way to do this is (at the moment) to use the SimConnect ClientData are functions to exchange data:

SimConnect_AddToClientDataDefinition Used to add an offset and a size in bytes, or a type, to a client data definition.
SimConnect_CreateClientData Used to request the creation of a reserved data area for this client.
SimConnect_MapClientDataNameToID Used to associate an ID with a named client date area.
SimConnect_RequestClientData Used to request that the data in an area created by another client be sent to this client.
SimConnect_SetClientData Used to write one or more units of data to a client data area.
SimConnect_ClearClientDataDefinition Used to clear the definition of the specified client data.

I am looking into this at the moment.


Hi, Did you found any solution for sending data from WASM module to a SimConeect Client?

I have created a WASM module and a SimConnect Client and can send Events from the client to WASM trigger H: Events. That is working fine. But, how to send Lvar data that can only be found in the WASM module to the client, is still not working.

I am looking into this at the moment. You need to use the SimConnect Client Data area to exchange data between your WASM module and the client (see my previous post).

I am wondering which of the functions should be in the WASM module and which should be in the client(external/exe)?

I guess that:
hr = SimConnect_MapClientDataNameToID(hndl, my_Data_NAME, my_Data_ID);

hr = SimConnect_AddToClientDataDefinition(hndl, my_Data_DEFINITION, 0, sizeof(my_Data), 0, 0);

hr = SimConnect_RequestClientData(hndl, my_Data_ID, my_REQUEST, my_Data_DEFINITION,

should be in the client and the other in the WASM. Is that correct?

1 Like

In the WASM:
  hr = SimConnect_CreateClientData(hSimConnect, …
Then, on each update:

In the client:
   hr=SimConnect_RequestClientData(hSimConnect, …

1 Like

I have a sample here that registered two client areas and exchanges data:

I have a WASM module that reads Lvars and sets Events for a specific airplane in the Community folder.
It is working fine, but could it be located in the Panel folder of the airplane so it is active only when the selected airplane is running in the sim? When it is in the Community folder it is loaded and running for all airplanes. I want it to take as little CPU resources as possible.

My repo above has the panel version in the linked commit, and the dev branch has the module version. The registration is a little different but yes you can do exactly what you want to do.

You register it like this:


But you should look at the above link because the gauge callback also needs to be there unlike the module version that doesn’t require it. Something like MSFS_CALLBACK bool BridgeGauge_gauge_callback(FsContext ctx, int service_id, void* pData)

panel registration: Read LVARs from C# · davuxcom/fs-gauge-bridge@3daa8cc · GitHub
module registration: fs-gauge-bridge/BridgeGauge.cpp at dev/external-avionics · davuxcom/fs-gauge-bridge · GitHub

Thanks, I will try to put it in the Panel folder.

Do you know where to find the airplane XLM files? E.g. B787_10_Interior.xml.

I know how to find and read them in the ModelBehaviorsDebug window, but it is not possible to make a copy of anything there.

The reason you can’t find it is because deluxe airplanes are encrypted. I think the filenames are xml.fsarchive, model.fsarchive and cfg.fsarchive.

OK, I found the none deluxe airplane XMLs

Thanks, you have been most valuable in getting me further into coding these airplanes.

1 Like

This is great and the first good outline of how to set up a SimConnect ClientData within a WASM that I have seen. I am also trying to send LVar values to my SimConnect client. The SimConnect_RequestClientData setup I think I can manage as long as I have the WASM set up correctly. I am very confused on the use of the SimConnect_CallDispatch and the FSAPI EventHandler and the role they play in a WASM module in regards to ClientData. I was able to bind keys to any LVar I could find using one of the below links but that communication only went one way for me (SimConnect Client to WASM). I need, for example, the FMC Zero key to send an event to my SimConnect client when I click it in the Sim.

I started with this post:
Demo: LVAR write access for any aircraft control

and using PMGD, P3D samples and this post:
Client Data area problems
managed to slap this together:

HANDLE  hSimConnect;
FLOAT64 testData = 321;

static enum DATA_DEFINE_ID {

extern "C" MSFS_CALLBACK void module_init(void)
	hSimConnect = 0;
	hr = SimConnect_Open(&hSimConnect, "Standalone Module", nullptr, 0, 0, 0);
	if (hr == S_OK)
		cout << "LVar Module Iniatialized" << endl;
		hr = SimConnect_MapClientDataNameToID(hSimConnect, "(>H:AS01B_FMC_1_BTN_0)", 1);
		hr = SimConnect_CreateClientData(hSimConnect, 1, 8, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED);
		hr = SimConnect_SetClientData(hSimConnect, 1, DEFINITION_1,	0, 0, sizeof(FLOAT64), &testData);

I think I understand how to structure it on the SimConnect_RequestClientData side of things if my WASM was correct. Any suggestions or links to examples I don’t know about would be greatly appreciated. Thanks!

Sorry, misread your code in my first response.
The code you posted is just creating a client data area with name “(>H:AS01B_FMC_1_BTN_0)” and setting a hard-coded value to it. Seems a strange thing to do, as I thought hvars are for executing only (and without a parameter)? Or are you mixing up hvars (for activating) with lvars (for reading/writing)?

Anyway, if you want to read that value then you need to just map to that client data area name on your client as you do in your WASM but use RequiestClientData instead.

To do this, you just need to know what event the clicking of the FMC Zero key produces, and then register for that event in your SimConnect client. There is no WASM module necessary - although you can of course register for that event in your WASM module as well.

I’m putting the finishing touches to my WASM module + client API implementation, and hope to release this as a beta in the next week or so. I’ll provide more details of the approach I’ve taken and the API provided in the next day or so.

LATER: I have posted more information on this in the following topic: Demo: LVAR write access for any aircraft control - #68 by ImpoliteGem5317

Thank you so much @ImpoliteGem5317. I look forward to following your work

I have now released an initial version of the FSUIPC WASM module + client API + test client. Please see WASM Module + Client API for MSFS / FSUIPC7 now available (for developers and advanced users only!) - Announcements - The simFlight Network Forums.

Source also in github.

For comments/suggestions/discussion on this, please use the following:
FSUIPC WASM module + client-side API + lvar/hvar discussion topic - FSUIPC7 MSFS - The simFlight Network Forums

Still lacking documentation - I’ll at least add some READMEs to the github repos in the next few days.