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 Sinks

Now that you have the ChatServer component in place, you’ll build the ChatClient component. As shown earlier in Figure 10-2, this component implements a COM object that is an event sink that will receive all messages fired off by the event source object in the ChatServer component. Specifically, as soon as the ChatServer component receives a chat message, it sends the same message back to all connected ChatClients through the client’s event sink object, shown in Figure 10-2 as CoMsgSink. The CoMsgSink object supports a callback interface called IReceiveMessage that the ChatServer component can utilize to make callbacks. Recall that you’ve defined this interface earlier in the last section, but you haven’t implemented it. You’ll do that in this section.

Besides implementing an event sink in this section, you’ll see the special contribution of this chapter in the subsection on Joining and Leaving a Chat Discussion where you contact the ChatBroker to find a ChatServer. You get a handle to the ChatServer via an interface pointer. Remember that this interface pointer is passed from the ChatServer to the ChatBroker to the ChatClient in the form of an OBJREF, and an OBJREF is the key that opens up distributed computing.

Creating the ChatClient Project

Our goal in this section is to develop a client application that looks similar to the one shown in Figure 10-3. So let’s use the MFC AppWizard EXE to create a Dialog base application and name this project ChatClient.

Creating the ...

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