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

Referrers

Referrers or brokers are so named because they are responsible for referring clients to a particular object. In some systems, clients usually don’t know where the target servers run, but they know one important agent, the broker, who can refer them to the appropriate servers. Typically, servers register themselves with a broker when they start up. When a client asks the broker for a particular service, the broker will return the registered server that supports the requested service. Brokers can do much more than this; for example, load balancing is something that can be done by the broker to equally distribute server loads. However, referrals are enough to illustrate the importance of the OBJREF.

Therefore, in our exercise, we’ll create a ChatBroker to refer a ChatClient to an appropriate ChatServer. As alluded to earlier, a ChatServer uses the IRegisterChatServer interface to register itself by passing its ISendMessage interface pointer to the ChatBroker. The ChatBroker keeps a list of ISendMessage interface pointers exposed by ChatServers, each representing a particular discussion topic. From this discussion list, a ChatClient may choose to join one of these discussions. Once the choice is made, the ChatBroker passes the ISendMessage interface pointer to the ChatClient. The ChatClient uses the ISendMessage to send chat messages to the ChatServer, even though it has no idea where in cyberspace the ChatServer runs.

Creating the ChatBroker Component

Let’s start off by creating ...

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