diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java index 0e51f0e252..6f4de42ee3 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java @@ -22,7 +22,6 @@ public final class NetworkTable { private final String m_path; private final String m_pathWithSep; private final NetworkTableInstance m_inst; - private final MultiSubscriber m_topicSub; /** * Gets the "base name" of a key. For example, "/foo/bar" becomes "bar". If the key has a trailing @@ -115,8 +114,6 @@ public final class NetworkTable { m_path = path; m_pathWithSep = path + PATH_SEPARATOR; m_inst = inst; - m_topicSub = - new MultiSubscriber(inst, new String[] {m_pathWithSep}, PubSubOption.topicsOnly(true)); } /** @@ -533,7 +530,7 @@ public final class NetworkTable { final NetworkTable parent = this; return m_inst.addListener( - m_topicSub, + new String[] {m_pathWithSep}, EnumSet.of(NetworkTableEvent.Kind.kPublish, NetworkTableEvent.Kind.kImmediate), new Consumer() { final Set m_notifiedTables = new HashSet<>(); @@ -583,8 +580,4 @@ public final class NetworkTable { public int hashCode() { return Objects.hash(m_inst, m_path); } - - void close() { - m_topicSub.close(); - } } diff --git a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp index 16cd04f197..1f6a7608d5 100644 --- a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp +++ b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp @@ -88,14 +88,9 @@ std::vector NetworkTable::GetHierarchy(std::string_view key) { NetworkTable::NetworkTable(NT_Inst inst, std::string_view path, const private_init&) - : m_inst(inst), - m_path(path), - m_topicSub{::nt::SubscribeMultiple(inst, {{fmt::format("{}/", path)}}, - {{PubSubOption::TopicsOnly(true)}})} {} + : m_inst(inst), m_path(path) {} -NetworkTable::~NetworkTable() { - ::nt::UnsubscribeMultiple(m_topicSub); -} +NetworkTable::~NetworkTable() = default; NetworkTableInstance NetworkTable::GetInstance() const { return NetworkTableInstance{m_inst}; @@ -405,8 +400,8 @@ NT_Listener NetworkTable::AddSubTableListener(SubTableListener listener) { // a shared_ptr to it. auto notified_tables = std::make_shared>(); - return ::nt::AddListener( - m_topicSub, NT_EVENT_PUBLISH | NT_EVENT_IMMEDIATE, + return NetworkTableInstance{m_inst}.AddListener( + {{fmt::format("{}/", m_path)}}, NT_EVENT_PUBLISH | NT_EVENT_IMMEDIATE, [this, cb = std::move(listener), notified_tables](const Event& event) { auto topicInfo = event.GetTopicInfo(); if (!topicInfo) { diff --git a/ntcore/src/main/native/include/networktables/NetworkTable.h b/ntcore/src/main/native/include/networktables/NetworkTable.h index 72ce20a4c6..d34f54bf2c 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTable.h +++ b/ntcore/src/main/native/include/networktables/NetworkTable.h @@ -48,7 +48,6 @@ class NetworkTable final { private: NT_Inst m_inst; std::string m_path; - NT_MultiSubscriber m_topicSub; mutable wpi::mutex m_mutex; mutable wpi::StringMap m_entries;