javascript - Invoke marshalled COM interface multiple times -
i writing com object javascript consumption. javascript code turn runs in hosted webbrowsercontrol. need fire events com object javascript, excellent guide @ dr. dobbs
e.g. have following in *.idl
ijscallback { void listen(idispatch* pjsmethod); }
javascript methods received idispatch*
in c++ code, stored calling later, thread. no matter method marshaling used (comarshalinterthreadinterfaceinstream
or iglobalinterfacetable
) event firing thread able call javascript function once. after idispatch::invoke()
returns e_accessdenied
!
sample javascript code
var server = new activexobject("prog_id") var.listen(function(ip_add) { // ip_add com object });
the c++ thread pretty straight forward.
// called javascript cmyobject::listen(idispatch* pjsmethod) { // istream* m_pstream; comarshalinterthreadinterfaceinstream(pjsmethod, iid_idispatch, &m_pstream); } // called internal c++ thread. cmyobject::fireevent() { // istream* m_pstream; // idispatch* m_pjsmethod; cogetinterfaceandreleasestream(m_pstream, iid_idispatch, (lpvoid*)&m_pjsmethod); hsreult hr = m_pjsmethod->invoke(...); // hr = s_ok, call received in javascript hr = m_pjsmethod->invoke(...); // hr = e_accessdenied, call not received in javascript }
is expected behavior? or wrong in code?
fixed. mentioned in comments alert()
works document.writeln()
doesn't. because document.writeln()
resets current document including scripts elements, use document.createelement()
, document.createtextnode()
, friends modify current loaded elements.
this common knowledge familiar html/javascript, rest of can real deal.
Comments
Post a Comment