Connection Points

This chapter asks you to think of an OBJREF every time an interface pointer is marshaled, but besides this, this chapter also focuses on bidirectional communications. It is obvious that a client can talk to a server by calling an interface method. However, there are times when you want the server to call back to the clients to notify them of events that are of interest.

Given the knowledge gained in this book so far, you can simply implement a COM object on the client side that exposes a callback interface for the server’s use. When special events occur, the server will call back to the client using the callback interface. This is a completely legal and straightforward technique for implementing bidirectional communications, but since bidirectional communications is a general need, Microsoft has developed a number of standard interfaces that support it. In COM terminology, bidirectional communications is supported by a mechanism called connection points.

This mechanism includes an event source[109] and an event sink. A COM object, such as an object within a ChatServer, that sends out event notifications is called an event source. For example, when a ChatServer object receives a chat message, it sends the same message out to all connected ChatClients. In other words, it propagates the same message to all chatters. On the other hand a COM object, such as an object within a ChatClient, that receives these broadcast messages or event notifications is a called an event ...

Get Learning DCOM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.