Session Management

A DirectPlay session is an instance of a game. The applications you design can use DirectPlay's session-management functions to open or close a communication channel, save a session in the registry, or enumerate past sessions that have been saved in the registry. A game either creates a new session or enumerates existing or previous sessions and finds one to connect to. If a game has saved a session, it could enumerate previous sessions and perhaps reconnect to the saved session. (This is a particularly appropriate scenario in a modem environment, where a saved session would include phone numbers.) Not all DirectPlay service providers will support saving sessions, however, and this functionality is currently only implemented for modem connections.

The IDirectPlay::Open method is used to create new sessions or to connect to existing or saved sessions. A session is described by its corresponding DPSESSIONDESC structure. This structure contains game-specific values and session particulars, such as the name of the session, an optional password for the session, and the number of players to be allowed in the session. After opening a session, you can call the IDirectPlay::GetCaps method to retrieve the speed of the communications link. To save a record of the session in the registry, call the IDirectPlay::SaveSession method. For a modem connection, you can save the current session and later enumerate all of the saved sessions by calling IDirectPlay::EnumSessions and specifying the DPENUMSESSIONS_PREVIOUS flag. Opening one of these saved sessions retrieves the phone number for that session and dials it. When a game session is over, it can be closed with the IDirectPlay::Close method.