if(it == connectedNodes.end()) { // if not exist, insert connectedNodes.insert(std::make_pair(sender, time)); } else { // exist, update time it->second = time; }
// display a textbox above the RSU icon in the map showing the number of connected nodes findHost()->getDisplayString().setTagArg("t", 0, connectedNodes.size()); }
// checking disconnected nodes by iterating the map for(it = connectedNodes.begin(); it != connectedNodes.end(); it++) { // if the last report time of a specific node is 3 seconds ago, assume it's disconnected if (simTime() - it->second >= 3) { connectedNodes.erase(it++); if (it == connectedNodes.end()) { break; } } } }
lastReceiveAt = simTime(); // alter the color of the component by editing the display string findHost()->getDisplayString().setTagArg("i", 1, "green");
if (simTime() - lastReceiveAt >= 3) { // alter the color of the component by editing the display string findHost()->getDisplayString().setTagArg("i", 1, "white"); } }