Changeset 8ed6c8a in network-game for common/MessageProcessor.cpp
- Timestamp:
- Jan 14, 2018, 6:44:45 PM (7 years ago)
- Branches:
- master
- Children:
- 8cbeffc
- Parents:
- e2a0a27
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/MessageProcessor.cpp
re2a0a27 r8ed6c8a 32 32 msg->id = ++lastUsedId; 33 33 MessageContainer message(*msg, *dest); 34 message.setTimeSent(getCurrentMillis()); 34 35 35 36 if (outputLog) … … 107 108 map<unsigned int, map<unsigned long, MessageContainer> >::iterator it; 108 109 map<unsigned long, MessageContainer>::iterator it2; 109 map<unsigned long, MessageContainer> sentMsg;110 map<unsigned long, MessageContainer>* sentMsg; 110 111 111 112 for (it = sentMessages.begin(); it != sentMessages.end(); it++) { 112 sentMsg = it->second; 113 for (it2 = sentMsg.begin(); it2 != sentMsg.end(); it2++) { 113 114 unsigned long long maxAge = 0; 115 sentMsg = &(it->second); 116 117 for (it2 = sentMsg->begin(); it2 != sentMsg->end(); it2++) { 114 118 if (!(it2->second.getAcked())) { 119 cout << "Maybe resending message" << endl; 120 cout << "time sent: " << it2->second.getTimeSent() << endl; 121 unsigned long long age = getCurrentMillis() - it2->second.getTimeSent(); 122 123 cout << "age: " << age << endl; 124 if (maxAge < age) { 125 maxAge = age; 126 cout << "new max age: " << maxAge << endl; 127 } 128 129 if (maxAge > 10000) { 130 cout << "id " << it2->second.getMessage()->id << " is not getting acked" << endl; 131 // this will prevent the message from getting resent anymore 132 it2->second.setAcked(true); 133 cout << "acked after being set: " << it2->second.getAcked() << endl; 134 } 135 115 136 sendto(sock, (const char*)it2->second.getMessage(), sizeof(NETWORK_MSG), 0, (struct sockaddr *)&it2->first, sizeof(struct sockaddr_in)); 116 137 } 138 } 139 140 if (maxAge > 10000) { 141 cout << "Connection lost" << endl; 117 142 } 118 143 }
Note:
See TracChangeset
for help on using the changeset viewer.