C# DirectPlay lobby launch not working?

  • Thread starter Thread starter Moshe Bergman
  • Start date Start date
M

Moshe Bergman

I am trying to launch Flight Simulator 2004, and have it connect to
localhost, I can do this in C++ but not on C#...

Here is my code:

ConnectInformation info = new ConnectInformation();
ConnectionSettings settings = new ConnectionSettings();
settings.HostAddress = new Microsoft.DirectX.DirectPlay.Address("127.0.0.1",
23456);;
Guid g = new Guid("0808caa5-e62c-4691-8957-5d4524b922da");
info.Flags = ConnectFlags.LaunchNew;
info.GuidApplication = g;
info.ConnectionSettings = settings;
info.UseConnectionSettings = false;
connectioninfo = theClient.ConnectApplication(info, 60000, null);
theClient.SetConnectionSettings(connectioninfo, settings);

if I change info.UseConnectionSettings to true, the program crashes, if it's
false, the program is launched but does not connect to the multiplayer.

Any help will be approciated,
Moshe Bergman
 
Moshe,

I'm also trying to interface to MSFS2004 using DirectX/Managed/C#. I've had
some luck by modifying the "Migrated Hosts" sample program under the
"Tutorials" directory.

The furthest I was able to get was to see the FS "Host" session returned
using "Peer.FindHost()", and have it "Reject" my attempt to connect with
"Peer.Connect()". Since I didn't format the data in the "Connect" packet,
I'm not surprised at the rejection.

Have you made any more progress on this?
 
You might want to look into the COM reference: DirectX 7 for Visual Basic Type Library.

I have played about with this and have managed to get it to launch the game, but all I can see is the "Joining multiplayer game" screen.
No matter what I try I can't get to the hosting screen. Maybe someone else can look into this?

I'd love to hear a solid explanation on how to use these functions.
Code:
[size=2][color=#0000ff][size=2][color=#0000ff]using [/color][/size][/color][/size][size=2]DxVBLib;[/size][size=2][color=#008000][size=2][color=#008000]
 
[/color][/size][/color][/size]
Code:
[size=2][color=#2b91af][size=2][color=#2b91af]DirectX7Class[/color][/size][/color][/size][size=2] dx7c = [/size][size=2][color=#0000ff][size=2][color=#0000ff]new [/color][/size][/color][/size][size=2][color=#2b91af][size=2][color=#2b91af]DirectX7Class[/color][/size][/color][/size][size=2]();
 
[/size][size=2][color=#2b91af][size=2][color=#2b91af]DirectPlayEnumServiceProviders[/color][/size][/color][/size][size=2] dpesp = dx7c.GetDPEnum();
 
[/size][size=2][color=#2b91af][size=2][color=#2b91af]Console[/color][/size][/color][/size][size=2].WriteLine(dpesp.GetCount() + [/size][size=2][color=#a31515][size=2][color=#a31515]" service providers found"[/color][/size][/color][/size][size=2]);
 
[/size][size=2][color=#0000ff][size=2][color=#0000ff]string[/color][/size][/color][/size][size=2] serviceguid = dpesp.GetGuid(4);[/size][size=2][color=#008000][size=2][color=#008000]// TCP/IP
 
[/color][/size][/color][/size][size=2][color=#2b91af][size=2][color=#2b91af]Console[/color][/size][/color][/size][size=2].WriteLine([/size][size=2][color=#a31515][size=2][color=#a31515]"Using: "[/color][/size][/color][/size][size=2] + serviceguid);
 
[/size][size=2][color=#2b91af][size=2][color=#2b91af]DirectPlay4[/color][/size][/color][/size][size=2] dp4 = dx7c.DirectPlayCreate(serviceguid);
 
[/size][size=2][color=#2b91af][size=2][color=#2b91af]DirectPlaySessionData[/color][/size][/color][/size][size=2] dpsd = dp4.CreateSessionData();[/size][size=2][color=#008000][size=2][color=#008000]
 
[/color][/size][/color][/size][size=2]dpsd.SetFlags([/size][size=2][color=#2b91af][size=2][color=#2b91af]CONST_DPSESSIONFLAGS[/color][/size][/color][/size][size=2].DPSESSION_DIRECTPLAYPROTOCOL | [/size][size=2][color=#2b91af][size=2][color=#2b91af]CONST_DPSESSIONFLAGS[/color][/size][/color][/size][size=2].DPSESSION_MIGRATEHOST);[/size][size=2][color=#008000][size=2][color=#008000]//is this right?
 
[/color][/size][/color][/size][size=2]dpsd.SetGuidApplication([color=#a31515]"{0808caa5-e62c-4691-8957-5d4524b922da}"[/color][size=2][/size]);[color=#008000]//flight simulator GUID (as shown in dxdiag)[/color][/size][size=2][color=#008000][size=2][color=#008000]
 
[/color][/size][/color][/size][size=2][color=#2b91af][size=2][color=#2b91af]DirectPlayLobby3[/color][/size][/color][/size][size=2] dpl3 = dx7c.DirectPlayLobbyCreate();
 
[/size][size=2][color=#008000][size=2][color=#008000]
 
[/color][/size][/color][/size][size=2][color=#2b91af][size=2][color=#2b91af]DirectPlayLobbyConnection[/color][/size][/color][/size][size=2] dplc = dpl3.CreateConnectionData();[/size][size=2][color=#008000][size=2][color=#008000]
 
[/color][/size][/color][/size][size=2]dplc.SetFlags([/size][size=2][color=#2b91af][size=2][color=#2b91af]CONST_DPLCONNECTIONFLAGS[/color][/size][/color][/size][size=2].DPLCONNECTION_CREATESESSION);
 
[/size][size=2][color=#008000][size=2][color=#008000]
 
[/color][/size][/color][/size][size=2]dplc.SetSessionDesc(dpsd);
 
[/size][size=2][color=#0000ff][size=2][color=#0000ff]int[/color][/size][/color][/size][size=2] res = dpl3.RunApplication(dplc, 0);[/size][size=2][color=#008000][size=2][color=#008000]//what is 0 for?
 
[/color][/size][/color][/size][size=2][color=#2b91af][size=2][color=#2b91af]Console[/color][/size][/color][/size][size=2].WriteLine([/size][size=2][color=#a31515][size=2][color=#a31515]"RunApplication result: "[/color][/size][/color][/size][size=2] + res);[/size][size=2]
[/size]
 
Last edited:
I have played about with this and have managed to get it to launch the game, but all I can see is the "Joining multiplayer game" screen.
No matter what I try I can't get to the hosting screen. Maybe someone else can look into this?

hi, yo know a solution for this?? can get to the hosting screen? i need something for get the hosting screen of age of empires II, thanks... sorry my english :( bye ;)
 
Back
Top