Direct Play Interfaces

Created by Jijith Nadumuri at 28 Apr 2010 12:20 and updated at 28 Apr 2010 12:54

DirectPlay Interfaces

The DirectPlay API is the network component of DirectX. The interfaces of this API enables programmers to write network applications such as multiplayer games. DirectPlay performs all of the hard work associated with connecting players. It allows you to create, find, and connect to multiplayer games. Once connected, DirectPlay enables you to send messages to other players. A common framework for launching applications and voice communications is also provided.

DirectPlay network service providers support communication over Transmission Control Protocol/Internet Protocol (TCP/IP), Internetwork Packet Exchange (IPX), modem, and serial links. An application programmer need not worry about these network protocols.

The core of the DirectPlay networking capabilities is the DirectPlay Transport Protocol. This protocol does not provide secure communications. But it has the following features:-

  • reliable/unreliable, sequential / non-sequential delivery of messages,
  • message fragmentation and reassembly,
  • congestion control,
  • message prioritization and message timeout during sending.

The communication model used for networking can be a peer-to-peer model or a client-server model, with or without voice communications. The network based games some times use a lobby (a common platform where game players can meet and arrange games). The interaction of a game player with a network game is called a gaming session.

Unless otherwise specified, all the DirectPlay interfaces are created by the CoCreateInstance method by passing the appropriate interface ID.

DirectPlay Core Interfaces

DirectPlay core interfaces includes the interfaces for peers, clients and servers in a peer-to-peer or client-server network games.

IDirectPlay8Peer

The IDirectPlay8Peer interface represents a peer-to-peer gaming session. It is used to create a peer-to-peer gaming session, create player groups, add players to a group, send messages to other players, register with a lobby etc.

IDirectPlay8Client

The IDirectPlay8Client interface represents a client application in a client-server gaming session. It is used to connect the client application with a server application , send messages to server application, register with a lobby etc.

IDirectPlay8Server

The IDirectPlay8Server interface represents a server application in a client-server gaming session. It is used to host a client-server gaming session, create player groups, add players to a group, send messages to a cleint or a group, register with a lobby etc.

Direct Play Lobby Interfaces

A lobby is a common platform where game players can meet and arrange games. Two interfaces are used to make a lobby based network games.

IDirectPlay8LobbyClient

The IDirectPlay8LobbyClient interface represents a lobby client application in a lobby enabled gaming session. A lobby client application is implemented by the lobby operator and runs on client computers. It allows the lobby server to communicate with client systems. It is used to connect with a lobby (a lobby server application), to launch a lobby server application if is is not already running (This is called lobby launching.), to send messages to the lobby etc.

IDirectPlay8LobbiedApplication

The IDirectPlay8LobbiedApplication interface represents a a lobby server application, otherwise called a lobby, in a lobby enabled gaming session. A lobby is launched by a lobby client. A lobby server application is implemented by the lobby operator and runs on the server computer. It is also called a lobbied application, an application that can act as a lobby (a common platform where game players can meet and arrange games). This interface is used to register an application as lobby launchable (this enables it to run as a lobbied application or in otherwords a lobby server application). It is also used to send messages to lobby clients.

Direct Play Voice Interfaces

Direct Play Voice API does not duplicate session control features from DirectPlay. However it uses a DirectPlay session for media-independent network transport and player management. A DirectPlay network transport session must be created before DirectPlay Voice can transmit and receive voice communications. DirectPlay Voice can use either the IDirectPlay4 object or IDirectPlay8 object for network transport.

DirectPlay Voice is also integrated with DirectSound for voice recording and playback, and all DirectPlay Sound audio features are inherited including the ability to target voice data to different playback buffers and the use of special audio effects such as 3D sound positioning.

DirectPlay session and DirectPlay Voice session are separate entities. There are no guarantees about message order between these two interfaces.

IDirectPlayVoiceClient

The IDirectPlayVoiceClient interface represents voice-client in a voice enabled client-server gaming session. The client may be mapped to some location in the game universe, in which case, the voice of the client is implemented as a 3D sound located somewhare in the game universe. The interface is used to connect the client to the voice session, create necessary 3D sound buffers etc.

IDirectPlayVoiceServer

The IDirectPlayVoiceClient interface represents voice-server in a voice enabled client-server gaming session. The interface is used perform tasks like starting a voice session etc.

IDirectPlayVoiceTest

The IDirectPlayVoiceTest interface is used to test Microsoft DirectPlay Voice audio configuration. It runs a series of tests on the devices to determine if they are capable of full duplex audio and to ensure that the microphone is plugged in and working correctly on the capture device.

DirectPlay Interfaces for network addressing

+++IDirectPlay8Address

The IDirectPlay8Address represents an address, that is used for the network communication. In order to deliver messages, each participant in a multiplayer game must have a unique address. Addresses can refer to either the computer on which your application is running (device address), or a computer with which your application needs to communicate (host address). DirectPlay represents addresses in the form of a URL string. That address string is then encapsulated in a DirectPlay address object that is passed as a parameter in or out of DirectPlay interface methods such as IDirectPlay8Peer::Connect.

All DirectPlay URLs thus have the following general form:- x-directplay:/[data string]

Here x-directplay is called the scheme, :/ is called the scheme separator and [data string] represents a data string. The data string does not conform to any Internet standard, and should just be passed on to the receiving application without modification. Such data strings are called opaque data strings. The scheme seporator :/ indicates that the following data string is opaque.

There are two basic approaches to handling address objects:

  • Handle the data string directly, using normal string manipulation techniques.
  • Use the methods exposed by IDirectPlay8Address to obtain or modify the individual elements of the data string.

Creation method:- CoCreateInstanceEx

IDirectPlay8AddressIP

The IDirectPlay8AddressIP represents an IP address that is used for Internet Protocol (IP) based network communcation. IP addresses takes the form of dotted machine address like 127.0.0.1 or a valid host name like www.microsoft.com. The interface will store a provider name (always CLSID_DP8SP_TCPIP) and port number along with the IP address. The addresses can refer to either the computer on which your application is running (device address), or a computer with which your application needs to communicate (host address).

IDirectPlay8NATResolver

The IDirectPlay8NATResolver interface acts as a server that resolves NAT addresses. This interface is used to improve connectivity for players behind Network Address Translation (NAT) devices that are not Universal Plug and Play (UPnP). This interface is only for players using the IPv4 service provider. (IPv4 and IPv6 are two versions of Internet Protocol. IPv6 is the latest version. IPv4 is the current version.). This interface acts as a simple server (NAT address reslover server) , which accepts queries and reflects the perceived address back to the caller.

Network Address Translation (NAT) is a mechanism with which one network can be connected to another. This is commonly used to connect a private home or office network to the Internet. The gateway between these two networks modifies packets sent from the private network to computers on the Internet so that they appear to have been sent by the gateway. When packets are sent back from the Internet to the gateway, the gateway forwards the packet on to the associated private computer. This improves security of the private network (NAT software additionally has capabilities to filter out any packets that are potentially harmful). This also increases the address space available to Internet as NAT devices allow private computers to share a single IP address. Firewalls and proxy servers also act as NAT devices.

IDirectPlayNATHelp

The IDirectPlayNATHelp interface helps in resolving Network Address Translation (NAT) by acting as a client to the NAT address reslover server. This interface is used to simplify traversal through the Internet Connection Sharing features available in Windows ME and Windows XP. This interface interacts with Internet gateway servers.

Other Interfaces

IDP8SimControl

The IDP8SimControl interface is used to create a DP8Sim session and test applications under a variety of network conditions by simulations. There is an executable called DP8Sim utility that uses the methods of IDP8SimControl to allow you to test your application under a variety of network conditions. Alternatively, you can use the DP8Sim service provider and IDP8SimControl interface to create your own test environment.

DP8Sim is implemented on top of the existing DirectPlay8 TCP/IP Service Provider. The settings are also applied on top of the existing network characteristics. Therefore, it is intended to be used on a high-speed local area network (LAN) where normal latency and packet loss are negligible.

The DP8Sim service provider, in other words, the DirectPlay8 TCP/IP Service Provider (Network Simulator), will be enumerated as a service provider in the list of service providers returned by the enumeration-methods of DirectPlay peer, client or server interfaces.

The following network parameters can be simulated:-

  • Bandwidth (bytes/second),
  • Drop percentage (0 to 100 percent),
  • Minimum latency (milliseconds),
  • Maximum latency (milliseconds)

IDirectPlay8ThreadPool

The IDirectPlay8ThreadPool interface represents a thread pool. The thread pool manages the threads in an ordinary DirectPlay application and defines a common pool of data for the threads. This interface cannot be used to manage threads in a DirectPlay Voice application. DirectPlay Voice uses a different set of threads to perform audio capture, playback, and message notification. Similary it cannot be used in conjunction with serial and modem service providers.

The IDirectPlay8ThreadPool avoid multithreading of the application by the programmer by providing DirectPlay’s own internal worker-threads to perform the various multithreading tasks of the application.

Share:- Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License