O'Reilly logo

Learning DCOM by Thuan L. Thai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Event Sources

In this section, you will create the ChatServer component that exposes a COM object called an event source. This COM object, which you’ll name ChatServerObj, supports the ISendMessage interface for ChatClients to post chat messages. It also supports a connection point associated with a callback interface called IReceiveMessage that is implemented by the ChatClient component (which will be developed in the Event Sinks section of this chapter). The ChatServer uses this callback interface to propagate chat messages to all chatters

Figure 10-2 shows the connections between a ChatClient and a ChatServerObj COM object. Notice that besides ISendMessage, ChatServerObj implements the IConnectionPointContainer interface to allow a client to find a particular supported connection point.

ChatServerObj is a source object and CoMsgSink is a sink object

Figure 10-2. ChatServerObj is a source object and CoMsgSink is a sink object

As you can see from Figure 10-2, the server component supports a connection point object that is associated with the IReceiveMessage interface, implemented by a client-side sink object, CoMsgSink. The client simply finds a connection point using the IConnectionPointContainer interface and tells the connection point that it wants to receive notifications by calling IConnectionPoint::Advise. The event source will make callbacks to the sink object at appropriate times.

Creating an Event Source Object

Our immediate goal is to create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required