DirectPlay help...or maybe simpler?
I have been trying to learn DirectPlay with the assistance of MSDN and the source code bundled with the directX 8.1 SDK.
Problem: Connection works fine, server successfully retrieves client data, but in the following attempt to send a welcome message from the server, the output on the client's side is "Server Sent: " instead of "Server Sent: Welcome to the Server!" I've been going over my code over and over again.. I am pretty sure directplay is not the problem, more likely I've lost something essential in the conversion of and output of data.
Related code in header file included in both server and client program:
#define MAX_CHAT_LENGTH 40
#define GAME_MSGID_BROADCAST 6
struct GAMEMSG_BROADCAST : public GAMEMSG_GENERIC
CHAR strBroadcast[MAX_CHAT_LENGTH]; // message to be sent
Code in server program:
msgBroadcast.dwType = GAME_MSGID_BROADCAST;
strcpy (msgBroadcast.strBroadcast,"Welcome to the Server!");
bufferDesc.dwBufferSize = sizeof(GAMEMSG_BROADCAST);
bufferDesc.pBufferData = (BYTE*) &msgBroadcast;
g_pDPServer->SendTo( dpnidNewPlayer, &bufferDesc, 1,
0, NULL, NULL, DPNSEND_SYNC );
Code in client program:
pReceiveMsg = (PDPNMSG_RECEIVE)pMsgBuffer;
GAMEMSG_GENERIC* pMsg = (GAMEMSG_GENERIC*) pReceiveMsg->pReceiveData;
switch( pMsg->dwType )
// We're getting a text message from the server
pBroadcastMsg = (GAMEMSG_BROADCAST*)pReceiveMsg->pReceiveData;
printf("\nServer Sent: %S\n", (CHAR *) pBroadcastMsg->strBroadcast);
Now, I know that the data is sent. By adding in some debug code, I find that the above case IS triggered. However, all that is outputted is "Server Sent: " Other types of communication between the two programs have been successful, but I cannot get this one to work. What am I missing? What's wrong? I appreciate the help in advance!