Platform SDK: DirectX |
The DirectPlay4.SendEx method sends a message to another player, to a group of players, or to all players in the session. SendEx is an enhanced version of the DirectPlay4.Send method and has more options available. SendEx supports both guaranteed and nonguaranteed messages. It also enables you to send asynchronous messages and to set the priority and time-out of a message.
object.SendEx(fromPlayerId As Long, _ toPlayerId As Long, _ flags As CONST_DPSENDFLAGS, _ msg As DirectPlayMessage, _ priority As Long, _ timeOut As Long, _ context As Long) As Long
When this flag is used, the return value will be DPERR_PENDING if the message is put in the send queue. This is not a fatal error, but just a return value that lets you know the message did not get sent immediately.
Not all service providers support this option. If it is not supported, specifying a nonzero priority will return a DPERR_UNSUPPORTED error. Call DirectPlay4.GetCaps to determine if this option is supported or not.
Not all service providers support this option. If it is not supported, specifying a nonzero time-out will return a DPERR_UNSUPPORTED error. Call DirectPlay4.GetCaps to determine if this option is supported or not.
Returns a DirectPlay-generated ID for the message.
If the method fails, an error is raised and Err.Number may be set to one of the following values:
DPERR_BUSY |
DPERR_CONNECTIONLOST |
DPERR_INVALIDFLAGS |
DPERR_INVALIDPARAMS |
DPERR_INVALIDPLAYER |
DPERR_INVALIDPRIORITY |
DPERR_NOTLOGGEDIN |
DPERR_SENDTOOBIG |
DPERR_UNSUPPORTED |
This method returns DPERR_INVALIDPARAMS if the encrypted or signed flag is specified for a message that is not also specified as guaranteed. It returns DPERR_INVALIDPRIORITY if the priority value is not between 0 and 65535. It returns DPERR_UNSUPPORTED if you specify a nonzero priority and the service provider does not support priorities, or if you specify a nonzero time-out and the service provider does not support this option.
This method supports guaranteed and nonguaranteed messages. Messages sent guaranteed will not be blocked if there are pending messages waiting to be acknowledged by the receiver.
If a message is sent asynchronously, the message will be put into a send queue and the SendEx method will return immediately. A system message will be posted to the receive queue of the sending player indicating the result of the send.
You can give messages priorities. A message is sent when there are no higher-priority messages waiting to be sent and when there is available bandwidth.
You can give a message a time-out. If DirectPlay cannot deliver the message in the time specified, it will be canceled.
The DPSEND_SIGNED and DPSEND_ENCRYPTED flags cannot be used if the order of delivery of guaranteed messages is not preserved because the flag is set in the session description.
If messages are sent using different priorities, signing and encryption might not work. It is best for the application to decide on one priority level for secure messages and only use the security flag on that priority level. This is because validation of secure messages depends on the order in which they are received and prioritization might change this order.
If the DirectPlay protocol is active, it will attempt to throttle outbound network traffic. That is, it will not always send packets as fast as possible. It will send packets as fast as it can without overwhelming the inbound bandwidth of the receiving computer.
System messages are always sent guaranteed, whether or not the service provider natively supports guaranteed messages, and whether or not you set the DirectPlay protocol flag. The DirectPlay protocol will be used automatically to send system messages guaranteed.
For nonsystem messages, if an application sets the DirectPlay protocol flag and sends a message guaranteed (by setting the DPSEND_GUARANTEED flag), the message will be sent guaranteed whether the service provider supports guaranteed messages or not.
For nonsystem messages, if an application does not set the DirectPlay protocol flag and sends a message guaranteed, the message will be sent guaranteed only if the service provider supports it. If the service provider does not support guaranteed messages, the message will not be sent guaranteed, regardless of the DPSEND_GUARANTEED flag.
DirectPlay4.Send, DirectPlay4.CancelMessage, DirectPlay4.CancelPriority