Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comms: Reduce UDP Popups on Weak Links #12267

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Comms/UDPLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,15 @@ void UDPWorker::writeData(const QByteArray &data)
for (const std::shared_ptr<UDPClient> &target : _udpConfig->targetHosts()) {
if (!_sessionTargets.contains(target)) {
if (_socket->writeDatagram(data, target->address, target->port) < 0) {
emit errorOccurred(tr("Could Not Send Data - Write Failed!"));
qCWarning(UDPLinkLog) << "Could Not Send Data - Write Failed!";
}
}
}

// Send to all connected systems
for (const std::shared_ptr<UDPClient> &target: _sessionTargets) {
if (_socket->writeDatagram(data, target->address, target->port) < 0) {
emit errorOccurred(tr("Could Not Send Data - Write Failed!"));
qCWarning(UDPLinkLog) << "Could Not Send Data - Write Failed!";
}
}

Expand Down Expand Up @@ -426,6 +426,7 @@ void UDPWorker::_onSocketReadyRead()
buffer.reserve(BUFFER_TRIGGER_SIZE);
QElapsedTimer timer;
timer.start();
bool received = false;
while (_socket->hasPendingDatagrams()) {
const QNetworkDatagram datagramIn = _socket->receiveDatagram();
if (datagramIn.isNull() || datagramIn.data().isEmpty()) {
Expand All @@ -435,6 +436,7 @@ void UDPWorker::_onSocketReadyRead()
(void) buffer.append(datagramIn.data());

if ((buffer.size() > BUFFER_TRIGGER_SIZE) || (timer.elapsed() > RECEIVE_TIME_LIMIT_MS)) {
received = true;
emit dataReceived(buffer);
buffer.clear();
(void) timer.restart();
Expand All @@ -451,8 +453,8 @@ void UDPWorker::_onSocketReadyRead()
locker.unlock();
}

if (buffer.isEmpty()) {
emit errorOccurred(tr("No Data Available to Read!"));
if (!received && buffer.isEmpty()) {
qCWarning(UDPLinkLog) << "No Data Available to Read!";
return;
}

Expand Down
Loading