Changeset 1a47469 in network-game


Ignore:
Timestamp:
Dec 16, 2013, 2:49:26 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
b4c5b6a
Parents:
53d41ea
Message:

Logging out works correctly now

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • design/message_spec.txt

    r53d41ea r1a47469  
    1212MSG_TYPE_LOGOUT
    1313Client sends this message to logout. Contains no extra data. The server uses the sender address to determine which player sent it.
     14Server broadcasts a reply with the player id if logout was successfull or sends the sender's id and a string with an error message back to the original sender.
    1415
    1516MSG_TYPE_CHAT
  • server/server.cpp

    r53d41ea r1a47469  
    754754            }
    755755
     756            // broadcast to all players before deleting p from the map
     757            map<unsigned int, Player*>::iterator it;
     758            for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
     759            {
     760               cout << "Sent message back to " << it->second->name << endl;
     761               if ( msgProcessor.sendMessage(&serverMsg, sock, &(it->second->addr), &outputLog) < 0 )
     762                  error("sendMessage");
     763            }
     764
    756765            if (p->id < unusedPlayerId)
    757766               unusedPlayerId = p->id;
     
    759768            delete p;
    760769            strcpy(serverMsg.buffer+4, "You have successfully logged out.");
    761             broadcastResponse = true;
    762770         }
    763771
Note: See TracChangeset for help on using the changeset viewer.