Making Your Application Lobby Aware

The Application class in the Lobby namespace is how you can actually receive information after you've been launched from a lobby, as well as how you register your application as being lobby-aware. The act of registering your application is quite simple; we will look at this first.

In order to register your application, you will first need to create a ProgramDescription structure. At the very least, you will need to fill out the application GUID and name parameters, as well as the executable path and filename members. The others are optional. Then you can call either the RegisterProgram or UnregisterProgram method, depending on the operation you wish to perform.

We never actually looked at the constructor for the Application object yet though. While it's possible to create the object without any parameters, the majority of time you will want to detect whether you have been launched from a lobby client. Let's look at the overload with the most parameters, as every other overload is a subset of this one:

 public Application ( System.Int32 connectionHandle ,      Microsoft.DirectX.DirectPlay.Lobby.InitializeFlags flags ,      Microsoft.DirectX.DirectPlay.Lobby.ConnectEventHandler connectEventHandler ) 

The connection handle parameter is an out parameter that will be returned to you. If you were launched by a lobby client, this handle will be the same as the one returned from the ConnectApplicaton method. However, if you were not, you can expect this member to be zero. The InitializeFlags enumeration allows you to disable parameter validation, but for this context is wholly uninteresting. The last parameter is something we haven't seen before. This allows you to actually hook the Connect event before the object is created, mainly because the constructor can actually fire this event.

Once you've detected that you've been launched from a lobby client, you need to call the RegisterLobby method on the appropriate DirectPlay connection object you are using. In the Connect event handler, you can also detect whether there were any connection settings passed in, and if so, use them to get into a session. The ConnectionSettings structure that is included in the event arguments object has all the information you need to either host or join an existing session.



Managed DirectX 9 Graphics and Game Programming, Kick Start
Managed DirectX 9 Kick Start: Graphics and Game Programming
ISBN: B003D7JUW6
EAN: N/A
Year: 2002
Pages: 180
Authors: Tom Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net