I created a Com object using ATL C++
interface IHostObjectSample2 : IDispatch
{
[propget, id(2), helpstring("Property.")] HRESULT Property([out, retval] BSTR* stringResult);
[propput, id(2), helpstring("Property.")] HRESULT Property([in] BSTR stringValue);
};
dispinterface _IHostObjectSample2Events
{
methods:
[id(1), helpstring("message")] void Event();
};
coclass HostObjectSample2
{
[default] interface IHostObjectSample2;
[default, source] dispinterface _IHostObjectSample2Events;
};
I added the Com object to script using AddHostObjectToScript
m_Webview->AddHostObjectToScript(L"sample", &remoteObjectAsVariant));
I can call methods/functions from the Script side
I want to fire the event _IHostObjectSample2Events::Event
in c++ side and received it in the Javascript side
something like window.chrome.webview.hostObjects.sample.addEventListener("Event", () => { do something });