问题
I am fairly new to web development other than basic HTML5 website creation, I somehow understand the general structure but I still cannot understand fully especially electron and nodejs.
The other day I was going to create a webapp, which is similar to wysiwyg text editor but talks in between the browser (HTML5/js) with the backend (c++ script). What I first tried, was to have a c++ hello world script, which can be executed from the webapp built upon electron. I was able to run .exe as child_process but I couldn't get to further.
Now, I took myself a bit deeper research for looking into c/c++ addon from nodejs but still trying to understand. The basic examples on the nodejs doesn't seem to give me a full understanding on how to transfer data.
I'm sorry for the long paragraph to describe my status but in short, here are some questions:
- Can anyone give me an idea of how Electron/nodejs can be used as a browser-backend middle interface?
- Does anyone have a simple example / phedo-code with a propoer API use to talk in between nodejs-c++backend? Is nodejs c/c++ addon the only method ?
Thank you for reading! and I'll look forward anyone to help me understand.
回答1:
As you already figured out, Node.js offers the functionality you seek via its C/C++ Addons. Are you able to repoduce the basic callback example found at the Node.js API manual?
来源:https://stackoverflow.com/questions/37908639/electron-nodejs-with-c-class-in-backend