mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[ntcore] Various NT4 fixes (#4474)
* TopicListener: Fix Add() return values * Update PubSubOption poll storage documentation * Update NetworkTableEntry::GetValue() doc * Add documentation regarding asynchronous callbacks * Unpublish entry: set publisher to nullptr * Implement ValueListenerPoller default constructor * Remove SetNetworkIdentity, make parameter to StartClient * URI-escape client ID, improve error message * Add connected message with client id; also improve disconnected message a bit * Handle SetServers either before or after StartClient * Fix client use-after-free; also delay reconnect after disconnect to rate limit * Don't re-announce to already subscribed client; we especially don't want to send the last value again * Always accept in-order sets, only use timestamp for tiebreak * Fix LocalStorage::StartNetwork race * Remove unused/unimplemented function Also: * [glass] Remove debug print * [glass] Fix mpack string decoding * [cameraserver] Fix up startclient
This commit is contained in:
@@ -15,10 +15,7 @@
|
||||
class ConnectionListenerTest : public ::testing::Test {
|
||||
public:
|
||||
ConnectionListenerTest()
|
||||
: server_inst(nt::CreateInstance()), client_inst(nt::CreateInstance()) {
|
||||
nt::SetNetworkIdentity(server_inst, "server");
|
||||
nt::SetNetworkIdentity(client_inst, "client");
|
||||
}
|
||||
: server_inst(nt::CreateInstance()), client_inst(nt::CreateInstance()) {}
|
||||
|
||||
~ConnectionListenerTest() override {
|
||||
nt::DestroyInstance(server_inst);
|
||||
@@ -36,7 +33,7 @@ void ConnectionListenerTest::Connect(const char* address, unsigned int port3,
|
||||
unsigned int port4) {
|
||||
nt::StartServer(server_inst, "connectionlistenertest.ini", address, port3,
|
||||
port4);
|
||||
nt::StartClient4(client_inst);
|
||||
nt::StartClient4(client_inst, "client");
|
||||
nt::SetServer(client_inst, address, port4);
|
||||
|
||||
// wait for client to report it's connected, then wait another 0.1 sec
|
||||
|
||||
@@ -31,10 +31,7 @@ namespace nt {
|
||||
|
||||
class LocalStorageTest : public ::testing::Test {
|
||||
public:
|
||||
LocalStorageTest() {
|
||||
storage.StartNetwork(startup);
|
||||
storage.SetNetwork(&network);
|
||||
}
|
||||
LocalStorageTest() { storage.StartNetwork(startup, &network); }
|
||||
|
||||
::testing::StrictMock<net::MockNetworkStartupInterface> startup;
|
||||
::testing::StrictMock<net::MockNetworkInterface> network;
|
||||
|
||||
@@ -18,8 +18,6 @@ class TopicListenerTest : public ::testing::Test {
|
||||
public:
|
||||
TopicListenerTest()
|
||||
: m_serverInst(nt::CreateInstance()), m_clientInst(nt::CreateInstance()) {
|
||||
nt::SetNetworkIdentity(m_serverInst, "server");
|
||||
nt::SetNetworkIdentity(m_clientInst, "client");
|
||||
#if 0
|
||||
nt::AddLogger(server_inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
@@ -52,7 +50,7 @@ class TopicListenerTest : public ::testing::Test {
|
||||
|
||||
void TopicListenerTest::Connect(unsigned int port) {
|
||||
nt::StartServer(m_serverInst, "topiclistenertest.json", "127.0.0.1", 0, port);
|
||||
nt::StartClient4(m_clientInst);
|
||||
nt::StartClient4(m_clientInst, "client");
|
||||
nt::SetServer(m_clientInst, "127.0.0.1", port);
|
||||
|
||||
// Use connection listener to ensure we've connected
|
||||
|
||||
@@ -21,9 +21,7 @@ namespace nt {
|
||||
// Test only local here; it's more reliable to mock the network
|
||||
class ValueListenerTest : public ::testing::Test {
|
||||
public:
|
||||
ValueListenerTest() : m_inst{nt::CreateInstance()} {
|
||||
nt::SetNetworkIdentity(m_inst, "server");
|
||||
}
|
||||
ValueListenerTest() : m_inst{nt::CreateInstance()} {}
|
||||
|
||||
~ValueListenerTest() override { nt::DestroyInstance(m_inst); }
|
||||
|
||||
|
||||
@@ -77,9 +77,9 @@ class MockLocalStorage : public ILocalStorage {
|
||||
(override));
|
||||
MOCK_METHOD(void, NetworkSetValue, (NT_Topic topicHandle, const Value& value),
|
||||
(override));
|
||||
MOCK_METHOD(void, StartNetwork, (NetworkStartupInterface & startup),
|
||||
MOCK_METHOD(void, StartNetwork,
|
||||
(NetworkStartupInterface & startup, NetworkInterface* network),
|
||||
(override));
|
||||
MOCK_METHOD(void, SetNetwork, (NetworkInterface * network), (override));
|
||||
MOCK_METHOD(void, ClearNetwork, (), (override));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user