?/TD>
Microsoft DirectX 9.0

Communicating with DirectPlay Objects


Microsoft?DirectPlay?consists of a collection of Component Object Model (COM) objects. Each object exposes one or more interfaces that enable you to control various aspects of DirectPlay. For instance, the DirectPlay peer object (CLSID_DirectPlay8Peer) is used to manage peer-to-peer games.

You communicate with a DirectPlay object by calling the methods exposed by its interfaces. For instance, to send some data to another user in a peer-to-peer game, you would send a message by calling the IDirectPlay8Peer::SendTo method. DirectPlay then takes care of getting the message to its target.

DirectPlay communicates with your application through one or more callback functions. These functions are similar in principle to the familiar Window procedure. Your application implements the callback function and passes a pointer to the function to DirectPlay during initialization. When DirectPlay needs to communicate with your application, it calls the callback function and passes in two key items of information:

For instance, when the message sent in the above example arrives at its target, the target application's callback function will receive a message with a DPNMSGID_RECEIVE message ID, indicating that a message has arrived from another user. The accompanying structure contains the data.

Because much of DirectPlay messaging is multithreaded, it is critical that callback functions be properly implemented.



© 2002 Microsoft Corporation. All rights reserved.