Open uwejan opened 1 year ago
Most everything in the agent is done by JS, which itself is built ontop of Duktape, which exposes a basic ECMA Script engine. I have C code that adds support for several node like modules, for event dispatch, sockets, etc.. The main thing the agent C code does external to JS, is the control channel with the server. But I exposed a MeshAgent object in JS, so that the meshcore can do any type of processing with the control channel.
The certificate verification for the control channel is handled in C using OpenSSL, but I exposed the API to do it from JS, using the same APIs as node.
The msh file is initially passed to the agent, embedded in the executable. On the agent side, the msh can be accessed as a JS object by calling the global function _MSH()
This is informative. Thank you.
I am going to take sometime to wrap my head arround it. Will be coming back with more questions. Perhabs will make a flow chart that shows the communication flow between agent <=> server, and share a modifiable link here so you can correct me if am wrong.
Meanwhile. What would be the way to access JS from within C?
Say i created a JS file that is an JSON object and linked it to the ILibDuktape_Polyfills.c
.
here is the content of my JS before linking it this way https://github.com/Ylianst/MeshAgent/issues/167
var myMESH = {
MeshName: '',
MeshType:2,
MeshID:'xxxx',
ServerID:'xxxx',
MeshServer: 'xxxx',
...etc
}
module.exports = myMESH
Hey @krayon007
I wonder where the MeshAgent.js
file is located.
It is mentioned here.
https://github.com/Ylianst/MeshAgent/blob/c067e28ed660401d7facd80136ffe326ce884e2c/microscript/ILibDuktape_Polyfills.c#L751
Thank you.
That object doesn't have a js file. That is exposed directly from native, from agentcore.c
I am trying to understand the system flow between the server and agent and vice versa. I have read the pdfs and docs from server repo and aagents as well. I gusie what am trying to figure out is that, Waht role dose the js core/duktape have? Is the certificate verification, step1,2,3, done directly using c code or all done by the js. The other can .msh file be embeded within the core? Or can it be parsed as a server config property to the agent? Which will rais the other question, Is C or Js handeling .mes file?
Thanks in advance.