mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 23:25:33 +00:00
use at method of unordered_map
This commit is contained in:
@ -212,7 +212,7 @@ int main(int argc, char **argv) try {
|
||||
try {
|
||||
while (dcLocked->bufferedAmount() <= bufferSize) {
|
||||
dcLocked->send(messageData);
|
||||
sentSizeMap[label] = sentSizeMap.at(label) + messageData.size();
|
||||
sentSizeMap.at(label) += messageData.size();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << "Send failed: " << e.what() << std::endl;
|
||||
@ -235,7 +235,7 @@ int main(int argc, char **argv) try {
|
||||
try {
|
||||
while (dcLocked->isOpen() && dcLocked->bufferedAmount() <= bufferSize) {
|
||||
dcLocked->send(messageData);
|
||||
sentSizeMap[label] = sentSizeMap.at(label) + messageData.size();
|
||||
sentSizeMap.at(label) += messageData.size();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << "Send failed: " << e.what() << std::endl;
|
||||
@ -246,7 +246,7 @@ int main(int argc, char **argv) try {
|
||||
|
||||
dc->onMessage([id, wdc = make_weak_ptr(dc), label](variant<binary, string> data) {
|
||||
if (holds_alternative<binary>(data))
|
||||
receivedSizeMap[label] = receivedSizeMap.at(label) + get<binary>(data).size();
|
||||
receivedSizeMap.at(label) += get<binary>(data).size();
|
||||
});
|
||||
|
||||
dataChannelMap.emplace(label, dc);
|
||||
@ -280,7 +280,7 @@ int main(int argc, char **argv) try {
|
||||
for (const auto &[label, dc] : dataChannelMap) {
|
||||
if (dc->isOpen() && dc->bufferedAmount() <= bufferSize * byteToSendOnEveryLoop) {
|
||||
dc->send(tempMessageData);
|
||||
sentSizeMap[label] = sentSizeMap.at(label) + tempMessageData.size();
|
||||
sentSizeMap.at(label) += tempMessageData.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -387,7 +387,7 @@ shared_ptr<PeerConnection> createPeerConnection(const Configuration &config,
|
||||
try {
|
||||
while (dc->bufferedAmount() <= bufferSize) {
|
||||
dc->send(messageData);
|
||||
sentSizeMap[label] = sentSizeMap.at(label) + messageData.size();
|
||||
sentSizeMap.at(label) += messageData.size();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << "Send failed: " << e.what() << std::endl;
|
||||
@ -426,7 +426,7 @@ shared_ptr<PeerConnection> createPeerConnection(const Configuration &config,
|
||||
|
||||
if (dcLocked->bufferedAmount() <= bufferSize) {
|
||||
dcLocked->send(tempMessageData);
|
||||
sentSizeMap[label] = sentSizeMap.at(label) + tempMessageData.size();
|
||||
sentSizeMap.at(label) += tempMessageData.size();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << "Send failed: " << e.what() << std::endl;
|
||||
@ -451,7 +451,7 @@ shared_ptr<PeerConnection> createPeerConnection(const Configuration &config,
|
||||
try {
|
||||
while (dcLocked->isOpen() && dcLocked->bufferedAmount() <= bufferSize) {
|
||||
dcLocked->send(messageData);
|
||||
sentSizeMap[label] = sentSizeMap.at(label) + messageData.size();
|
||||
sentSizeMap.at(label) += messageData.size();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << "Send failed: " << e.what() << std::endl;
|
||||
@ -462,7 +462,7 @@ shared_ptr<PeerConnection> createPeerConnection(const Configuration &config,
|
||||
|
||||
dc->onMessage([id, wdc = make_weak_ptr(dc), label](variant<binary, string> data) {
|
||||
if (holds_alternative<binary>(data))
|
||||
receivedSizeMap[label] = receivedSizeMap.at(label) + get<binary>(data).size();
|
||||
receivedSizeMap.at(label) += get<binary>(data).size();
|
||||
});
|
||||
|
||||
dataChannelMap.emplace(label, dc);
|
||||
|
Reference in New Issue
Block a user