?/TD>
Microsoft DirectX 9.0

DataRelay


The DataRelay sample is similar to SimplePeer but differs by sending a packet of data with options specified in the dialog box's user interface (UI).

Path

Source: (SDK root)\Samples\C++\DirectPlay\DataRelay

Executable: (SDK root)\Samples\C++\DirectPlay\Bin

User's Guide

Host or connect to a session in the same manner as explained in SimplePeer. When the main dialog box appears, select the target, size, rate, and timeout values. Then click Push to Send. This will send a packet of data to the target—at the rate specified—with the specified size. Using the Connection Info drop-down menu, specify a target on which you would like to periodically gather connection information.

Note  If you choose the Internetwork Packet Exchange (IPX) service provider and want to have Microsoft?DirectPlay?perform a search for the address, select the use DPNSVR check box.

Programming Notes

The DataRelay sample is very similar in form to the SimplePeer sample. For detailed programming notes, see the Programming Notes section of the SimplePeer sample.

When the Push to Send button is clicked, a timer is created that goes off every number of milliseconds, as indicated by the UI.

When the timer goes off, the callback function calls the SendNetworkData function to do the following tasks.

  1. Create an application-defined structure.
  2. Create a GAMEMSG_DATA_NODE, which is handed off to the application worker thread. That thread processes the node and then updates the UI to show that a packet was sent.
  3. A DPN_BUFFER_DESC structure is filled out, passing in a pointer to the application-defined structure created above.
  4. The IDirectPlay8Peer::SendTo method is called, passing in the DPN_BUFFER_DESC structure.
  5. The event g_hDPDataAvailEvent is set, telling the worker thread that there is data ready to be processed.

On receipt of the g_hDPDataAvailEvent event, the ProcessNetDataProc function calls the ProcessData function, which does the following:

  1. Enters the critical section, g_csDataList.
  2. Runs through the linked list, processing each node.
  3. Calls IDirectPlay8Peer::ReturnBuffer so that DirectPlay can free buffer space that it passed in DPN_MSGID_RECEIVE.

The DirectPlayMessageHandler function handles different kinds of messages, such as DPN_MSGID_RECEIVE and DPN_MSGID_SEND_COMPLETE.



© 2002 Microsoft Corporation. All rights reserved.