Board index » cppbuilder » Firing COM/DCOM events in automation object
Dave Sampso
![]() CBuilder Developer |
Sun, 07 Dec 2003 06:05:34 GMT
|
Dave Sampso
![]() CBuilder Developer |
Sun, 07 Dec 2003 06:05:34 GMT
Firing COM/DCOM events in automation objectI am writing an automation server with events enabled so that I can notify the client when certain things happen. The Fire_<EventName>() method exists in several classes in the file <ProjectName>_TLB.h. One of these classes is for the client to sink the event. What I can't figure out is how to call the Fire method from the automation server. I have not found any examples of this in the Borland docs or anywhere else. Anybody know how to do this and/or where to find a good example? Thanks!! Dave |
Qimiao L
![]() CBuilder Developer |
Tue, 09 Dec 2003 06:25:12 GMT
Re:Firing COM/DCOM events in automation objectI'd also like to the sample. I have the same problems. Qim Quote"Dave Sampson" <dsamp...@qwest.net> wrote in message Quote
in several classes in the file <ProjectName>_TLB.h. One of these classes is for the client to sink the event. What I can't figure out is how to call the Fire method from the automation server. I have not found any examples of this in the Borland docs or anywhere else. Anybody know how to do this and/or where to find a good example? Thanks!! Quote
|
Alex Roschi
![]() CBuilder Developer |
Sat, 13 Dec 2003 03:20:40 GMT
Re:Firing COM/DCOM events in automation objectQuoteDave Sampson wrote: but I was forced to add COM support to the application that I make at my job, and I was given a very short time to do that. So I've found a *very bad and stupid* method to solve this problem - don't follow me if you feel you have a chance to find a normal way to solve it. So here's my solution: I've added 2 methods to my server: "SetupEvents" and "CleanupEvents". Every client In "SetupEvents" you should add the instance of T<your_server_name>Impl (this) I've tested it under Win98 and it worked well, but I don't know how many bugs If anybody knows how to do it normally - please let me know too... Here is the sample of my code: // ========= in T<your_server_name>Impl.cpp =============== Quote} { ClientList.DelElement(this); return S_OK; Quote} class TComObjectList { private: T<your_server_name>Impl **List; int Count; int FindElement(T<your_server_name>Impl *object); void Fire_Test_Event(void); TComObjectList(void){ List=NULL; Count=0;}; Quote}; TComObjectList ClientList; int TComObjectList::FindElement(T<your_server_name>Impl *object) Quote} void TComObjectList::AddElement(T<your_server_name>Impl *object) // ..... Quote} void TComObjectList::DelElement(T<your_server_name>Impl *object) if(index<0) return; // ..... Quote} void TComObjectList::Fire_Test_Event(void) Quote} Yours faithfully, |
Steve Co
![]() CBuilder Developer |
Sun, 14 Dec 2003 01:18:45 GMT
Re:Firing COM/DCOM events in automation objectAlex, I think your solution will work fine. You don't need to add functions for starting to recieve events, though. You If you add a destructor, you can remove yourself from your list at that I used a static TList in my Implementation class to add the instances to, so Quote"Alex Roschin" <rochi...@yahoo.com> wrote in message Quote> Dave Sampson wrote: - Quote> TComObjectList ClientList; - Quote
- Quote
- Quote
- - Hide quoted text - - Show quoted text - Quote
|
Dave
![]() CBuilder Developer |
Sun, 14 Dec 2003 04:34:03 GMT
Re:Firing COM/DCOM events in automation objectHi Alex & Steve, Thanks for your ideas. I had given up hope that anyone was actually going to respond! Since my original post, I found a lot of useful information in the book C++ Builder5 Developer's Guide by Sam's Publishing. My understanding of the event processing is that the macros in the server code actually implement the connection point list (of connected clients) for you, so you don't need to keep it yourself. You should be able to call the Fire_<event> method one time, regardless of how many clients are connected, and they all will get the notification. But since I can't get to the Fire_<event> method from the server object, maybe you do have to call it for each instance... I'm going to play with your idea and see where it takes me. Thanks! Dave |
Alex Roschi
![]() CBuilder Developer |
Mon, 15 Dec 2003 20:48:28 GMT
Re:Firing COM/DCOM events in automation objectQuoteSteve Cox wrote: The idea sounds good, but I can't make it work. It looks like the implementation // ... ~TExpRemoteControlImpl() I can see the "AddElement" message when the client connects to the server, but I use single-use server model so I actually don't need to manage multiple clients, Yours faithfully, |
Steve Co
![]() CBuilder Developer |
Mon, 15 Dec 2003 20:56:39 GMT
Re:Firing COM/DCOM events in automation objectAlex, The ~TExpRemoteControlImpl() destructor should be called when the client Quote"Alex Roschin" <rochi...@yahoo.com> wrote in message Quote> Thanks Steve! |
Alex Roschi
![]() CBuilder Developer |
Tue, 16 Dec 2003 03:53:57 GMT
Re:Firing COM/DCOM events in automation objectQuote> Alex, Client program deletes the object it created to interact with the server - BTW I've experimented with the Borland's examples "AutoCon" and "AutoSrv" - Yours faithfully, |
1. DCOM: Can I create all COM objects as DCOM object
2. Automation object doesn't fire events
3. Firing an Automation object event
4. DCOM Automation Object events in BCB 5.0
5. COM object - handling automation events programmatically
6. DCOM Fire Events - Asynchronous calls
7. Fire DCom-events to the specified clients
8. Firing Events From a Automation Server
9. Automation Object X COM Object
10. For Binh Ly - Automation Objects vs Standard COM Objects