Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Magmai Kai - (et all) need dplay8 help

This topic is 6273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey Magmai (or anyone) I posted this in the Dx forum, and Magmai suggested I try out this one..(thanks dude). I''m just trying to get a simple dplay8 project going..I''m looking for some help creating a basic UDP client/server app going but I''m not sure how to *properly* setup my dplay8 objects.. Yes I''m in the process of reading the sdk docs, and YES I do understand client/server, peer-peer theory (this will be my first mplayer project..) Any samples other than the sdk docs would be helpfull, or even some suggestions as to what I need to remember (ie. any "gotchas").. thanks for any advice/help, Wazoo

Share this post


Link to post
Share on other sites
Advertisement
Hi wazoo69, here is a snippet of code I use to initialize Direct Play for a peer-to-peer session.

  
HRESULT hrInitializeDirectPlay( HWND hWindow )
{
HRESULT hReturn;
int i;

// Initialize COM

hReturn = CoInitialize( NULL );
if( FAILED(hReturn) ) {
MessageBox( hWindow, "Error Initializing COM", "DirectPlay Error", MB_ICONERROR );
return hReturn;
}

// Initialize critical sections for multi-threading

InitializeCriticalSection( &g_csModifyPlayer );

// Create IDirectPlay8Peer Object

if( FAILED( hReturn = CoCreateInstance( CLSID_DirectPlay8Peer,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDirectPlay8Peer,
(LPVOID*) &g_pDP ) ) )
MessageBox( hWindow, "Can't Create DPlayPeer", "DirectPlay Error", MB_ICONERROR );

// Init IDirectPlay8Peer Message Handler

if( FAILED( hReturn = g_pDP->Initialize( NULL, DirectPlayMessageHandler, 0 ) ) ) {
MessageBox( hWindow, "Failed to Message Handler", "DirectPlay Error", MB_ICONERROR );
return -1;
}

// Create a device address

hReturn = CoCreateInstance( CLSID_DirectPlay8Address, NULL,CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*) &g_pDeviceAddress );
if( FAILED(hReturn) ) {
MessageBox( hWindow, "Failed to Create Device", "CoCreateInstance()", MB_ICONERROR );
return -1;
}

// Set our service provider to TCP/IP

if( FAILED( hReturn = g_pDeviceAddress->SetSP( &CLSID_DP8SP_TCPIP ) ) ) {
MessageBox( hWindow, "Failed to SetSP() for Device Address", "Invalid Param", MB_ICONERROR );
return -1;
}

// Create a host address

hReturn = CoCreateInstance( CLSID_DirectPlay8Address, NULL,CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*) &g_pHostAddress );
if( FAILED(hReturn) ) {
MessageBox( hWindow, "Failed to Create Host Address()", "Invalid Param", MB_ICONERROR );
return -1;
}
// Set the host address to TCP/IP

if( FAILED( hReturn = g_pHostAddress->SetSP( &CLSID_DP8SP_TCPIP ) ) ) {
MessageBox( hWindow, "Failed to SetSP() for Host Address", "Invalid Param", MB_ICONERROR );
return -1;
}

// Create connection complete event for later use

g_hConnectCompleteEvent = CreateEvent( NULL, FALSE, FALSE, NULL );

vShowText(hLB_Output,"<<--TCP INITED-->>");

// Init miscellaneous variables

for( i = 0 ; i < MAX_PLAYERS ; i++ ) {
PlayerInfo[i].bActive = 0;
}

return S_OK;
}


webmaster@lostlogic.com
www.lostlogic.com


Edited by - lostlogic on March 18, 2001 11:10:40 AM

Share this post


Link to post
Share on other sites
Thanks LostLogic!! That''s what I needed to getting started!

(Of course I''ll modify it for client/server, but I get the general idea..)

thanks, and I''ll definitely look at your book when it comes out!

Wazoo

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!