Changes in / [8cbeffc:033c78b] in network-game
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/MessageProcessor.cpp
r8cbeffc r033c78b 32 32 msg->id = ++lastUsedId; 33 33 MessageContainer message(*msg, *dest); 34 message.setTimeSent(getCurrentMillis());35 34 36 35 if (outputLog) … … 108 107 map<unsigned int, map<unsigned long, MessageContainer> >::iterator it; 109 108 map<unsigned long, MessageContainer>::iterator it2; 110 map<unsigned long, MessageContainer> *sentMsg;109 map<unsigned long, MessageContainer> sentMsg; 111 110 112 111 for (it = sentMessages.begin(); it != sentMessages.end(); it++) { 113 114 unsigned long long maxAge = 0; 115 sentMsg = &(it->second); 116 117 for (it2 = sentMsg->begin(); it2 != sentMsg->end(); it2++) { 112 sentMsg = it->second; 113 for (it2 = sentMsg.begin(); it2 != sentMsg.end(); it2++) { 118 114 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 anymore132 it2->second.setAcked(true);133 cout << "acked after being set: " << it2->second.getAcked() << endl;134 }135 136 115 sendto(sock, (const char*)it2->second.getMessage(), sizeof(NETWORK_MSG), 0, (struct sockaddr *)&it2->first, sizeof(struct sockaddr_in)); 137 116 } 138 }139 140 if (maxAge > 10000) {141 cout << "Connection lost" << endl;142 117 } 143 118 }
Note:
See TracChangeset
for help on using the changeset viewer.