[glass] NT view: clear meta-topic info on disconnect (#4732)

This commit is contained in:
Peter Johnson
2022-11-29 21:57:48 -08:00
committed by GitHub
parent 9b319fd56b
commit e9bd50ff9b

View File

@@ -432,6 +432,27 @@ void NetworkTablesModel::Update() {
}
}
if (event.flags & nt::EventFlags::kUnpublish) {
// meta topic handling
if (wpi::starts_with(info->name, '$')) {
// meta topic handling
if (info->name == "$clients") {
m_clients.clear();
} else if (info->name == "$serverpub") {
m_server.publishers.clear();
} else if (info->name == "$serversub") {
m_server.subscribers.clear();
} else if (wpi::starts_with(info->name, "$clientpub$")) {
auto it = m_clients.find(wpi::drop_front(info->name, 11));
if (it != m_clients.end()) {
it->second.publishers.clear();
}
} else if (wpi::starts_with(info->name, "$clientsub$")) {
auto it = m_clients.find(wpi::drop_front(info->name, 11));
if (it != m_clients.end()) {
it->second.subscribers.clear();
}
}
}
auto it = std::find(m_sortedEntries.begin(), m_sortedEntries.end(),
entry.get());
// will be removed completely below