diff --git a/code/components/voip-mumble/include/MumbleClientImpl.h b/code/components/voip-mumble/include/MumbleClientImpl.h index a204e1dcd8..add282b535 100644 --- a/code/components/voip-mumble/include/MumbleClientImpl.h +++ b/code/components/voip-mumble/include/MumbleClientImpl.h @@ -239,7 +239,11 @@ class MumbleClient : public IMumbleClient, public Botan::TLS::Callbacks bool m_hasUdp = false; - std::chrono::milliseconds m_lastUdp; + bool m_udpTimedOut = false; + + // the time in milliseconds since the player joined the mumble server + // This is used to determine if we should allow UDP warnings + std::chrono::milliseconds m_timeSinceJoin; std::chrono::milliseconds m_nextPing; diff --git a/code/components/voip-mumble/src/MumbleClient.cpp b/code/components/voip-mumble/src/MumbleClient.cpp index bf804324f5..7100344abd 100644 --- a/code/components/voip-mumble/src/MumbleClient.cpp +++ b/code/components/voip-mumble/src/MumbleClient.cpp @@ -39,7 +39,6 @@ void MumbleClient::Initialize() m_voiceTarget = 0; - m_lastUdp = {}; m_nextPing = {}; m_loop = Instance::Get()->GetOrCreate("mumble"); @@ -116,6 +115,7 @@ void MumbleClient::Initialize() // don't start idle timer here - it should only start after TLS handshake is done! + m_timeSinceJoin = msec(); m_connectionInfo.isConnected = true; }); @@ -166,11 +166,6 @@ void MumbleClient::Initialize() m_idleTimer = m_loop->Get()->resource(); m_idleTimer->on([this](const uvw::TimerEvent& ev, uvw::TimerHandle& t) { - if (m_hasUdp && (msec() - m_lastUdp) > kUDPTimeout) - { - m_hasUdp = false; - console::PrintWarning("mumble", "Server isn't responding to UDP packets, swapping to TCP.\n"); - } auto lockedIsActive = [this]() { @@ -428,7 +423,6 @@ concurrency::task MumbleClient::ConnectAsync(const net::P m_tcpPingCount = 0; - m_lastUdp = {}; memset(m_tcpPings, 0, sizeof(m_tcpPings)); @@ -782,8 +776,6 @@ void MumbleClient::HandleUDP(const uint8_t* buf, size_t size) return; } - // update UDP timestamp - m_lastUdp = msec(); // handle voice packet HandleVoice(outBuf, size - 4); @@ -971,10 +963,21 @@ void MumbleClient::HandlePing(const MumbleProto::Ping& ping) m_crypto.m_remoteLost = ping.lost(); m_crypto.m_remoteResync = ping.resync(); - if (m_hasUdp && (m_crypto.m_remoteGood == 0 || m_crypto.m_localGood == 0) && (msec() - m_lastUdp) > 2s) + if (m_hasUdp && (m_crypto.m_remoteGood == 0 || m_crypto.m_localGood == 0) && (msec() - m_timeSinceJoin) > 20s) { - console::PrintWarning("mumble", "UDP packets can *not* be received. Switching to TCP tunnel mode.\n"); m_hasUdp = false; + if (m_crypto.m_remoteGood == 0 && m_crypto.m_localGood == 0) + { + console::PrintWarning("mumble", "UDP packets cannot be sent or received from the server. Switching to TCP mode."); + } + else if (m_crypto.m_remoteGood == 0) + { + console::PrintWarning("mumble", "UDP packets cannot be received by the server. Switching to TCP mode."); + } + else + { + console::PrintWarning("mumble", "UDP packets cannot be received from the server. Switching to TCP mode."); + } } else if (!m_hasUdp && m_crypto.m_remoteGood > 3 && m_crypto.m_localGood > 3) {