Changeset 6b641af in network-game for common/MessageProcessor.cpp


Ignore:
Timestamp:
Jul 16, 2013, 1:06:57 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
4dbac87
Parents:
5755e68
Message:

Debugging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/MessageProcessor.cpp

    r5755e68 r6b641af  
    3535   int ret =  recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)source, &socklen);
    3636
     37   if (ret == -1)
     38      return ret;
     39
    3740   // add id to the NETWORK_MSG struct
    3841   if (msg->type == MSG_TYPE_ACK) {
     
    4144         sentMessages[msg->id].isAcked = true;
    4245         sentMessages[msg->id].timeAcked = getCurrentMillis();
    43       }else
    44          cout << "Received old ack" << endl;
     46      }
    4547
    4648      return -1; // don't do any further processing
     
    7577
    7678   while (it != sentMessages.end()) {
    77       if (it->second.isAcked && (getCurrentMillis() - it->second.timeAcked) > 1000)
    78          sentMessages.erase(it++);
    79       else
     79      if (it->second.isAcked) {
     80//         cout << "Found acked message" << endl;
     81//         cout << "time acked" << it->second.timeAcked << endl;
     82//         cout << "cur time" << getCurrentMillis() << endl;
     83         if ((getCurrentMillis() - it->second.timeAcked) > 1000) {
     84            cout << "Message was acked. time to delete it" << endl;
     85            cout << "old map size" << sentMessages.size() << endl;
     86            sentMessages.erase(it++);
     87            cout << "new map size" << sentMessages.size() << endl;
     88         }else
     89            it++;
     90      }else
    8091         it++;
    8192   }
Note: See TracChangeset for help on using the changeset viewer.