DirectX SDK |
The DirectPlay4.Open method is used to join a session that has been enumerated by a previous call to the DirectPlay4.GetDPEnumSessions method or to create a new session that other users can enumerate and join.
object.Open(sessionDesc As DirectPlaySessionData, _ flags As CONST_DPOPENFLAGS)
If a session is to be created, then the application must completely initialize the DirectPlaySessionData object with the properties of the session to be created, except for the GuidInstance, which DirectPlay will supply.
If the method fails, an error is raised and Err.Number may be set to one of the following values:
This method returns DPERR_ALREADYINITIALIZED if there is already an open session on this DirectPlay object.
It return DPERR_CANTCREATEPLAYER if the maximum number of players in the session description has already been reached.
It returns DPERR_TIMEOUT if the session did not respond to the Open request.
It returns DPERR_USERCANCEL if the user canceled the enumeration process (usually by canceling a service provider dialog box).
It returns DPERR_NOSESSIONS if there is no open session matching the description, if the session isn't in the internal session list, or the session GUID is corrupted.
After an application has joined a session, it can create a player and start communicating with other players in the session. The application will not receive any messages nor can it send any messages on this DirectPlay object until it creates a local player using DirectPlay4.CreatePlayer.
In order to have two sessions open simultaneously, the application must create two DirectPlay objects and open a session on each one.
DirectPlaySessionData.SetSessionPassword must be called if the session was marked as password protected. An enumerated session will have the DPSESSION_PASSWORDREQUIRED flag set if it requires a password.
If joining a secure session, you must use DirectPlay4.SecureOpen to provide logon credentials. The enumerated session will have the DPSESSION_SECURESERVER flag set if it requires credentials.
If you specify the DPSESSION_SECURESERVER flag, the session will be opened with the default security package, NTLM. To specify an alternate security package, use SecureOpen.
When an application attempts to join a session, the server can reject the Open request or ignore it (in which case Open will time-out). Attempting to join a session where new players are disabled, joining is disabled, the player limit has been reached, or an incorrect password is supplied will result in a DPERR_NONEWPLAYERS or DPERR_INVALIDPASSWORD error.