Sharing "complex" Data between .wasm Module and Javascript. #17957
Unanswered
mergintaim
asked this question in
Q&A
Replies: 1 comment
-
There are several ways to communicate data between JS and WebAssembly. They are documented here: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I have a C++ Applikation(it visualizes some data, running once natively and once using emscripten to run it in the browser) that I build straight to wasm via the "-o *.html" flag. On this website I am using some custom JS Code to retrieve and sanitize some data and I am left with an array of ints, floats and string variables. It already has the same size and makeup as the corresponding struct on the C++ side. How can I share this data easily between the JS in the browser and the .wasm in the browser.
The struct on the C side looks like this, just a lot more variables per datapoint:
typedef struct
{
int sample;
char timestamp[20];
char characteristics;
int pollrate;
float temperature;
float lux;
char sys_name[64];
} datapoint;
I am guessing I have to write a function that accesses the memory used by Javascript and then using offsets(by knowing the datatype and size in the JS/Browser Memory) but I was thinking there might be an easier way I am not seeing. However so far I have had no luck actually finding the correct "array" in the browser memory to find the right offsets/adresses.
I am sorry if this is too basic(I am a student) or not in the scope of this project.
Beta Was this translation helpful? Give feedback.
All reactions