1

I have a c#.NET class having an Event signature which is exposed to COM using an outgoing interface like this::

[ComVisible(true)]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IHehServerEvents
    {
       string EmptyEvent(object sender, CustomEventArgs args);
    }

In PluginAPI.h>> I have

class PluginAPI: public IHehServerEvents,public FB::JSAPIAuto//implemented the COM outgoing interface
{

//declared EmptyEvent method based upon tlh file

 HRESULT __stdcall EmptyEvent(VARIANT sender,IUnknown * args, BSTR * pRetVal);
        FB_JSAPI_EVENT(CSharpEvent, 2, (FB::variant,IUnknown *));

    }
    HRESULT ClassCpluss::EmptyEvent(BSTR message, BSTR * pRetVal)
    {....}

My Event helper in Firebreath statement is

FB_JSAPI_EVENT(CSharpEvent, 2, (VARIANT,struct _EventArgs *));

I also saw THIS link. SO boost::vairant is supported right?Then how to cast VARIANT to boost::variant? Any changes expected in the above statement? How to handle the above event in c# by use of VARIANT or struct?any examples would be helpful..

0

1 Answer 1

1

No, boost::variant is not supported, FB::variant is supported -- it is not the same thing at all. FB::variant is actually using boost::any internally.

What you're trying to do is mix COM and FireBreath and it's not going to have a good result. Instead, create a class that talks to your COM stuff and use that from your JSAPI object. Handle the event in your object and have it call a functor (look at boost::bind and boost::function) or maybe use signals and sockets from boost. There are lots of ways you can handle it, but the key here is that you need to first get your C++ object that knows how to talk to COM and then using that object from FireBreath will be easy. Directly using a VARIANT or arbitrary struct type with firebreath events will never work.

Sign up to request clarification or add additional context in comments.

2 Comments

Surely knew about boost::function and boost::bind.But can you give us a link/provide an example(of handling COM events in c++) and as to what you're talking about this statement "have it call a functor (look at boost::bind and boost::function) "
I haven't done any handling of COM events in c++. To see an example of using a functor, look at the SimpleStreamsHelper class in the FireBreath codebase -- it uses a boost::function callback. To see it used, look at FBTestPlugin where it uses SimpleStreamsHelper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.