Thread: DirectPlay help...or maybe simpler?

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Unhappy 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_GENERIC
    {
    DWORD dwType;
    };

    struct GAMEMSG_BROADCAST : public GAMEMSG_GENERIC
    {
    CHAR strBroadcast[MAX_CHAT_LENGTH]; // message to be sent
    };





    Code in server program:

    GAMEMSG_BROADCAST msgBroadcast;
    msgBroadcast.dwType = GAME_MSGID_BROADCAST;
    strcpy (msgBroadcast.strBroadcast,"Welcome to the Server!");
    DPN_BUFFER_DESC bufferDesc;
    bufferDesc.dwBufferSize = sizeof(GAMEMSG_BROADCAST);
    bufferDesc.pBufferData = (BYTE*) &msgBroadcast;

    g_pDPServer->SendTo( dpnidNewPlayer, &bufferDesc, 1,
    0, NULL, NULL, DPNSEND_SYNC );




    Code in client program:

    case DPN_MSGID_RECEIVE:
    {
    PDPNMSG_RECEIVE pReceiveMsg;
    pReceiveMsg = (PDPNMSG_RECEIVE)pMsgBuffer;

    GAMEMSG_GENERIC* pMsg = (GAMEMSG_GENERIC*) pReceiveMsg->pReceiveData;
    switch( pMsg->dwType )
    {

    case GAME_MSGID_BROADCAST:
    {
    // We're getting a text message from the server
    GAMEMSG_BROADCAST* pBroadcastMsg;
    pBroadcastMsg = (GAMEMSG_BROADCAST*)pReceiveMsg->pReceiveData;
    printf("\nServer Sent: %S\n", (CHAR *) pBroadcastMsg->strBroadcast);
    break;
    };
    }

    break;
    }




    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!
    Last edited by Trireme; 02-14-2003 at 06:59 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectPlay or Winsock?
    By kevinawad in forum Networking/Device Communication
    Replies: 5
    Last Post: 10-20-2008, 07:12 PM
  2. DirectPlay & a DirectX question
    By Lurker in forum Game Programming
    Replies: 2
    Last Post: 02-24-2004, 05:37 PM
  3. OOP for DirectPlay Peer to Peer program
    By curlious in forum Networking/Device Communication
    Replies: 0
    Last Post: 11-04-2003, 12:21 AM
  4. DirectPlay?
    By Mecnels in forum Windows Programming
    Replies: 1
    Last Post: 04-07-2003, 09:07 AM
  5. mulitplayer and directPlay
    By phantom in forum Linux Programming
    Replies: 1
    Last Post: 03-29-2002, 12:51 AM