Microsoft DirectX 8.1 (Visual Basic) |
One way to arrange a session is to have session hosts advertise themselves as available. This type of session is referred to as a broadcast session. Peers or clients can look for a game to join by enumerating the available hosts, selecting one, and then join the game by sending a connection request. See Peer-to-Peer Sessions or Client/Server Sessions for a detailed discussion.
Unlike other enumerations, the information needed to respond to a request for available hosts is not stored on the local computer. Instead, a client or peer must broadcast a request, for instance on their local subnet, and wait for available hosts to respond. Hosts, on the other hand, must wait for these requests, and then respond appropriately. There are thus two slightly different procedures, depending on whether you are a potential session member, or a session host.
The following procedure illustrates how enumerate the available hosts for a peer-to-peer session. The procedure for a client/server session is essentially the same. DirectPlay8Peer.EnumHosts is the method that starts the enumeration. The key parameters to set are ApplicationDesc, Deviceinfo, and AddrHost.
Examine the information returned to your message handler, select a session, and ask to join it by calling DirectPlay8Peer.Connect.
If you want to be the host of a broadcast session, advertise yourself as available, and wait for queries or connection requests. The following procedure applies to peer-to-peer hosts, but is essentially similar to the procedure for client/server hosts.
See the Peer-to-Peer Sessions and Client/Server Sessions sections for further discussion of how to arrange and launch a game.