From 36c489247c5fe114e6d225ca4fa2d380dfc30760 Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Sun, 15 Feb 2026 00:46:38 -0500 Subject: [PATCH] [ntcore] Fix local client sending value updates before publish message (#8613) Text frames were being queued while binary frames were sent immediately. Change NetworkOutgoingQueue to send text frames immediately on local connections. Add asserts since local connections should now not be queueing at all. --- .../native/cpp/net/NetworkOutgoingQueue.hpp | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ntcore/src/main/native/cpp/net/NetworkOutgoingQueue.hpp b/ntcore/src/main/native/cpp/net/NetworkOutgoingQueue.hpp index e5579ccf7f..e9250369ab 100644 --- a/ntcore/src/main/native/cpp/net/NetworkOutgoingQueue.hpp +++ b/ntcore/src/main/native/cpp/net/NetworkOutgoingQueue.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -110,8 +111,21 @@ class NetworkOutgoingQueue { template void SendMessage(int id, T&& msg) { - m_queues[m_idMap[id].queueIndex].Append(id, std::forward(msg)); - m_totalSize += sizeof(Message); + if (m_local) { + m_wire.SendText([&](auto& os) { + if (!WireEncodeText(os, MessageType{std::forward(msg)})) { + os << "{}"; + } + }); + } else { + m_queues[m_idMap[id].queueIndex].Append(id, std::forward(msg)); + m_totalSize += sizeof(Message); + } + + if (m_local) { + // local connections should never have outgoing messages queued + assert(m_totalSize == 0); + } } void SendValue(int id, const Value& value, ValueSendMode mode) { @@ -160,9 +174,19 @@ class NetworkOutgoingQueue { break; } } + if (m_local) { + // local connections should never have outgoing messages queued + assert(m_totalSize == 0); + } } void SendOutgoing(uint64_t curTimeMs, bool flush) { + if (m_local) { + // local connections should never have outgoing messages queued + assert(m_totalSize == 0); + return; + } + if (m_totalSize == 0) { return; // nothing to do }