Changes in / [e607c0f:cdb4bec] in network-game


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    re607c0f rcdb4bec  
    9494   set_nonblock(sock);
    9595
    96    bool broadcastMessage;
     96   bool broadcastResponse;
    9797   while (true) {
    9898
     
    104104         cout << "Got a message" << endl;
    105105
    106          broadcastMessage = processMessage(clientMsg, from, vctPlayers, serverMsg);
     106         broadcastResponse = processMessage(clientMsg, from, vctPlayers, serverMsg);
    107107
    108108         cout << "msg: " << serverMsg.buffer << endl;
    109109
    110          if (broadcastMessage)
    111          {
     110         if (broadcastResponse)
     111         {
     112            cout << "Should be broadcasting the message" << endl;
     113
    112114            vector<Player>::iterator it;
    113115
     
    120122         else
    121123         {
     124            cout << "Should be sending back the message" << endl;
     125
    122126            if ( sendMessage(&serverMsg, sock, &from) < 0 )
    123127               error("sendMessage");
     
    139143   cout << "MSG contents: " << clientMsg.buffer << endl;
    140144
     145   // maybe we should make a message class and have this be a member
    141146   bool broadcastResponse = false;
    142147
     
    186191
    187192            vctPlayers.push_back(newP);
    188             strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with outher players.");
     193            strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with other players.");
    189194         }
    190195
     
    221226      case MSG_TYPE_CHAT:
    222227      {
     228         cout << "Got a chat message" << endl;
     229
    223230         Player *p = findPlayerByAddr(vctPlayers, from);
    224231
     
    232239
    233240            stringstream ss;
    234             ss << p->name << ": " << clientMsg.buffer << endl;
     241            ss << p->name << ": " << clientMsg.buffer;
    235242
    236243            strcpy(serverMsg.buffer, ss.str().c_str());
     
    249256         break;
    250257      }
    251 
    252       return broadcastResponse;
    253    }
    254 }
     258   }
     259
     260   return broadcastResponse;
     261}
     262
Note: See TracChangeset for help on using the changeset viewer.