Home : COM / OLE / ActiveX notes : Connections
Normally the client calls functions in an interface of the object. A connectable object (or source) also has the capability to call functions in interfaces (of a sink object) provided by the client, for the purpose of:
Events (or notifications): informing the client that some event has occurred.
Requests: querying the client to obtain to some information.
To establish a connection:
The client obtains the objects IConnectionPointContainer interface (by calling QueryInterface with an IID of IID_IConnectionPointContainer).
The client calls the IConnectionPointContainer interfaces FindConnectionPoint function, passing the IID of the sink interface to be used. If the object recognises this interface, it returns an IConnectionPoint interface.
The client calls the IConnectionPoint interfaces Advise function, passing the IUnknown interface of the sink. The connection point calls the sinks IUnknown interface to obtain the correct interface. A token value (or cookie) is returned to the client.
The object can now call the functions in the interface provided by the sink.
When the client calls the IConnectionPoint interfaces Unadvise function, passing the token value, the connection is broken.