Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.
I need to create a JS native function than will get return value from main process. I tried to use the example but I didn't understand how can I get value from main process and return it:
function TMyV8Handler.Execute(const name : ustring;
const obj : ICefv8Value;
const arguments : TCefv8ValueArray;
var retval : ICefv8Value;
var exception : ustring): Boolean;
begin
if (name = 'myfunc') then
begin
retval := TCefv8ValueRef.NewString('My Value!'); // <---- What I need to write here?
Result := True;
end
else
Result := False;
end;
Please help. I don't understand how to send message to the main process and wait for an answer.
If I understand you correctly, the easiest way to send information from the main process to JavaScript is to execute some custom JS code which embeds that information in the JS code, for example, as a parameter of a JS function.
Another way to do that is using process messages to the render process with an ICefProcessMessage that has your custom information in "ICefProcessMessage.ArgumentList".