?/TD>
Microsoft DirectX 9.0

IDirectPlay8Peer::Initialize Method


Registers an entry point in the peer's code that receives all the messages from the IDirectPlay8Peer interface and from remote peers. This method must be called before calling any other methods of this interface.

Syntax

HRESULT Initialize(      

    PVOID const pvUserContext,     const PFNDPNMESSAGEHANDLER pfn,     const DWORD dwFlags );

Parameters

pvUserContext
[in] Pointer to the user-provided context value in calls to the message handler. A user-provided context value can be used to differentiate messages coming from multiple interfaces to a common message handler.
pfn
[in] Pointer to a PFNDPNMESSAGEHANDLER callback function that is used to receive all messages from remote peers and indications of session changes from the IDirectPlay8Peer interface.
dwFlags
[in] You can specify the following flags.
DPNINITIALIZE_DISABLEPARAMVAL
Passing this flag will disable parameter validation for the current object.
DPNINITIALIZE_HINT_LANSESSION
Opens a larger send window for games running on a local area network (LAN).
DPNINITIALIZE_DISABLELINKTUNING
Disable any attempts by Microsoft?DirectPlay?to tune the rate it sends at to the observed network conditions. Messages will be pushed out onto the network at the first available opportunity.

Return Value

Returns S_OK if successful, or one of the following error values.

DPNERR_INVALIDFLAGSThe flags passed to this method are invalid.
DPNERR_INVALIDPARAMOne or more of the parameters passed to the method are invalid.


Remarks

Call this method first after using CoCreateInstance to obtain the IDirectPlay8Peer interface.

Specify the DPNINITIALIZE_HINT_LANSESSION flag for sessions where all players will be on the same LAN.

Applications might want to specify the DPNINITIALIZE_DISABLELINKTUNING flag when they send at a fixed rate and do not alter the rate based on the network conditions. With this flag specified, DirectPlay will always assume the network has the capacity to carry all the application data and will therefore not attempt to tune its send rate to the network bandwidth. Specifying this flag and then sending at a rate that exceeds the capacity of the network will lead to unpredictable network behavior such as higher latency and increased packet drop rates. Applications that monitor the send queues and dynamically adjust their send rate to make best use of the available bandwidth should not specify this flag.

If the DPNINITIALIZE_DISABLELINKTUNING flag is specified, DirectPlay features such as message prioritization, coalescence, and timeout are not useful because messages always go directly to the network and are not queued.



© 2002 Microsoft Corporation. All rights reserved.