Connecting an Add-On
Connecting an add-on to a multiplayer session accomplishes the following, in order:
-
Locates a multiplayer session to connect to.
-
Connects the add-on to a multiplayer session and creates a DirectPlay player.
-
Communicates with the session host to validate the player created by the add-on (as a player or an observer).
-
Determines the characteristics of the other players in the multiplayer session.
To connect an add-on to a Flight Simulator multiplayer session
-
Start Flight Simulator 98, as a host, making sure that there is room in the session for another player or observer.
-
Scan for available sessions using the DirectPlay EnumSessions function with the following application GUID specified in the SESSIONDESC2 structure.
GUID_FS6 = {0xcc080a27, 0x6d4e, 0x11d0, 0x8e, 0x21, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0xef};
-
Using the DirectPlay Open function, connect to the appropriate session.
-
Broadcast a packet to all players in the session using ADD_PLAYER_REQUEST or ADD_OBSERVER_REQUEST, depending on what type of add-on ("player" or "observer") you want to add to the session.
Wait for a response from the host player, such as CHANGE_TO_PLAYER, CHANGE_TO_OBSERVER, ADD_PLAYER_REFUSED, or ADD_OBSERVER_REFUSED.
-
If the host hasn't responded to a player's join request in a specified amount of time (30 seconds), send a RETRANSMIT_JOIN_PLAYER or RETRANSMIT_JOIN_OBSERVER packet and return to step 4.
-
If the response from the host is CHANGE_TO_PLAYER or CHANGE_TO_OBSERVER, check the player ID in the message data. If the player ID matches the player ID of the local player, the add-on is successfully connected to the session.
-Or-
If the response from the host is ADD_PLAYER_REFUSED or ADD_OBSERVER_REFUSED, the add-on wasn't able to connect to the session and needs to take appropriate action. For example, if the response from the host was ADD_PLAYER_REFUSED, the add-on could display a message informing the user that they couldn't join as a player and ask them if they want to join as an observer, instead.
Note: If the host doesn't allow the add-on to join the session, the add-on should end its connection to the session.