Grouplab DirectPlay

Microsoft's DirectPlay is a framework for designing multiplayer-over the network - applications (namely games). Grouplab DirectPlay is COM wrapper for DirectPlay, simplifying it for rapid prototyping in visual basic.

This wrapper simplifies DirectPlay by offering the basic features.

Grouplab DirectPlay provides:

  • Creation of sessions using TCP/IP as the transport protocol, utilizing either the client-server, peer-to-peer, or a hybrid model.
  • Management of 'players' connected to a session.
  • Management of message passing between connected players.
  • Utilization of the DirectPlay Protocol - allowing reliable/unreliable messaging, message priority and timeouts.
  • Event-based interface for dealing with events - much more suited to Visual Basic's programming model than 'native' DirectPlay.
  • Automatic Marshaling of message data for standard Variant types, and any COM types supporting marshall by value.
  • Key-Value Pair object, marshallable by value, and useful for storing in a dictionary object.

Grouplab DirectPlay does not provide the following:

  • IPX, Serial and Modem communication - only TCP/IP connections are allowed.
  • Lobbies - players connect to specific sessions.
  • Group Management - everything is done on the 'player' level.
  • DirectVoice protocol - no built-in interface for using voice audio communication.

Download Library

Sample

Notification Chat Server - Illustrates how clients and a server communcate to implement a chat system. In this example, the clients send messages to the server only, which then broadcasts them to all clients (including the original sender).

Server Client

 

GroupLab DirectPlay


Properties

Property Access Description
Players as GlabPlayersCollection Get By Reference Collection class for adding, enumerating and removing players in the current connected section.

Methods

Method Description
CreateSession (SessionName As String, [UseDPProtocol]) Create a new session on the local machine, deciding whether or not to use the DirectPlay Protocol instead of standard TCP/IP and UDP. Most applications should use this protocol to take advantage of: automatic throttling, message prioritization, message timeouts.
ConnectToSession (Host As String, SessionName As String) Connect to the named session on the given machine (either the ip address or machine name).
SendMessage (FromPlayerID As Long, ToPlayerID As Long, channelID As Byte, Msg, Guarantee, [Priority As Long], [Timeout As Long]) Send Data to specified receiver (0 to send to all, 1 to send to the server player, or the player's unique player id). The channel ID is a number from 0-255. This channel allows the receiver to know what kind of message has arrived without checking its value. The Message is cast as a Variant, and can be any variant type, or any COM object that can be marshalled by value. The Guarantee is a boolean operand signaling whether to use TCP/IP or UDP for transport. Priority is a integer ranging from 0 to 65535. The timeout value is used to cancel any messages that aren't sent out after the specified number of milliseconds elapse.
CloseSession () Disconnect from the current session.

Events

Method Description
OnConnected (SessionName As String) Occurs when a connection is successfully created to a local or remote session.
OnPlayerEnter (lPlayerID As Long) Occurs when a new player enters. Players do not receive events for their own entrance.
OnPlayerExit (lPlayerID As Long) Occurs when a new player exits. Players do not receive events for their own exit.
OnMessage (lFromPlayerID As Long, lToPlayerID As Long, channelID As Byte, varMsg) Occurs when a message is received for the player 'lToPlayer' from 'lFromPlayer'. Players do not receive messages they have sent out, even when addressed to 'all players'.

GlabPlayersCollection


Properties

Property Access Description
Item (index as long) Get By Reference Retrieve the player indexed player. Note: index is not the unique player id. Rather, it is the index of the player in the collection, with the first player having index 1.
Count as long Get by Value Number of players connected to current session.

Methods

Method Description
Add (PlayerName As String, IsServerPlayer) As Long Creates a new player on the open session, returning the new player's unique player id.
Remove (PlayerID As Long) Removes the player with the given unique player id. Only 'local' players can be removed.

GlabDirectPlayMessagePair


Properties

Property Access Description
Key as String Get, Set By Value Associated key for this object.
Value as Variant Get, Set By Value Variant Value for this object.
 

License Terms