DirectX SDK

DirectPlay4.SendChatMessage

The DirectPlay4.SendChatMessage method sends a text message to another player, a group of players, or all players. The player receiving the chat message is informed through a DPSYS_CHAT system message in the player's receive queue. This method must be used in a lobby session.

object.SendChatMessage(fromPlayerId As Long, _
    toPlayerId As Long, _
    flags As CONST_DPSENDFLAGS, _
    message As String) 

Parameters

object
Object expression that resolves to a DirectPlay4 object.
fromPlayerId
ID of the sending player. The player ID must correspond to one of the local players on this computer.
toPlayerId
ID of the player to send the message to, the ID of the group of players to send the message to, or DPID_ALLPLAYERS to send the message to all players in the session.
flags
Value indicating how the message should be sent. If this parameter is set to 0, the message is sent nonguaranteed.
DPSEND_GUARANTEED
Sends the message by using a guaranteed method of delivery if it is available.
message
Message to be sent.

Error Codes

If the method fails, an error is raised and Err.Number may be set to one of the following values:

DPERR_ACCESSDENIED
DPERR_CONNECTIONLOST
DPERR_INVALIDFLAGS
DPERR_INVALIDPARAMS
DPERR_INVALIDPLAYER

This method returns DPERR_INVALIDPARAMS if the toPlayerId ID is not a valid player or group. It returns DPERR_INVALIDPLAYER if the fromPlayerId ID is not a valid player. It returns DPERR_ACCESSDENIED if the fromPlayerId ID is not a local player.

Remarks

This method facilitates player-to-player chatting within a lobby session where different client applications can be connected. In an application session, chat messages can be sent by using the DirectPlay4.Send method.

The receiving player will receive a system message (fromPlayerId = DPID_SYSMSG).