DirectX SDK |
The DirectPlay4.Receive method retrieves a message from the message queue.
object.Receive(fromPlayerId As Long, _ toPlayerId As Long, _ flags As CONST_DPRECEIVEFLAGS) As DirectPlayMessage
If only DPRECEIVE_TOPLAYER is specified, Receive will only return messages sent to the player specified by toPlayerId.
If only DPRECEIVE_FROMPLAYER is specified, Receive will only return messages sent from the player specified by fromPlayerId.
If neither DPRECEIVE_TOPLAYER nor DPRECEIVE_FROMPLAYER is set, Receive will return the first available message.
If the method succeeds, it returns a DirectPlayMessage object whose methods can be used to retrieve the contents of the message, or Nothing if there are no messages pending.
If the method fails, an error is raised and Err.Number may be set to one of the following values:
DPERR_GENERIC |
DPERR_INVALIDOBJECT |
DPERR_INVALIDPARAMS |
DPERR_INVALIDPLAYER |
Messages that were sent to a player ID defined as DPID_ALLPLAYERS or to a group ID still appear to come from the sending player ID. An application will only receive messages directed to a local player. A player cannot receive a message in which the values pointed to by fromPlayerId and toPlayerId are equal.
If DPSESSION_NOMESSAGEID is specified in the session description, the fromPlayerId will always be 0xFFFFFFFF and the toPlayerId value is arbitrary.
All the service providers shipped with DirectPlay perform integrity checks on the data to protect against corruption. Any message retrieved using Receive is guaranteed to be free from corruption.