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 }