Changeset b8f789d in network-game


Ignore:
Timestamp:
Sep 26, 2013, 1:24:58 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
50e6c7a
Parents:
bbebe9c
Message:

The server broadcasts GAME_INFO messages in response to game creation and join messages from clients

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    rbbebe9c rb8f789d  
    926926         break;
    927927      }
     928      case MSG_TYPE_CREATE_GAME:
     929      {
     930         cout << "Received a CREATE_GAME message" << endl;
     931
     932         string gameName(clientMsg.buffer);
     933         cout << "Game name: " << gameName << endl;
     934
     935         // temp var
     936         int numPlayers = 0;
     937
     938         serverMsg.type = MSG_TYPE_GAME_INFO;
     939         memcpy(serverMsg.buffer, &numPlayers, 4);
     940         strcpy(serverMsg.buffer+4, gameName.c_str());
     941         broadcastResponse = true;
     942
     943         break;
     944      }
     945      case MSG_TYPE_JOIN_GAME:
     946      {
     947         cout << "Received a JOIN_GAME message" << endl;
     948
     949         string gameName(clientMsg.buffer);
     950         cout << "Game name: " << gameName << endl;
     951
     952         // temp var
     953         int numPlayers = 0;
     954
     955         serverMsg.type = MSG_TYPE_GAME_INFO;
     956         memcpy(serverMsg.buffer, &numPlayers, 4);
     957         strcpy(serverMsg.buffer+4, gameName.c_str());
     958         broadcastResponse = true;
     959
     960         break;
     961      }
    928962      default:
    929963      {
     964         serverMsg.type = MSG_TYPE_CHAT;
    930965         strcpy(serverMsg.buffer, "Server error occured. Report this please.");
    931 
    932          serverMsg.type = MSG_TYPE_CHAT;
    933966
    934967         break;
Note: See TracChangeset for help on using the changeset viewer.