Follow-up from PR review. Live instance/device state tracking currently rides inside
TeamChannelSubscriber alongside membership and team-update events. By the subscriber design, each
concern should be its own minimal subscriber.
Goal
- Add a dedicated
LiveStatusSubscriber for the p/+/state and d/+/state topics.
- Keep
TeamChannelSubscriber focused on membership and team updates.
- Hoist the shared connect/disconnect/message-routing boilerplate into
BaseSubscriber, with abstract
members for the topic list and the regex→handler map. New subscribers then just declare what they care
about.
Blocker to solve first
The two subscribers share the fe-team connection key, but mqttService.createClient(key) destroys any
existing client on that key — there's no "is anyone else using this key?" check:
// createClient(key)
if (this.hasClient(key)) {
await this._destroyClientUnlocked(key) // existing client torn down, not reused
}
// destroyClient(key) → _destroyClientUnlocked(key) — no refcount guard
So two subscribers on the same key tear each other down. Sharing the connection needs a
connectOrReuse-style entry point (name TBD) that reuses an existing client and tracks subscribers, so
teardown only happens once the last one detaches. Opening a separate client per subscriber is the
fallback but wastes a connection.
Follow-up from PR review. Live instance/device state tracking currently rides inside
TeamChannelSubscriberalongside membership and team-update events. By the subscriber design, eachconcern should be its own minimal subscriber.
Goal
LiveStatusSubscriberfor thep/+/stateandd/+/statetopics.TeamChannelSubscriberfocused on membership and team updates.BaseSubscriber, with abstractmembers for the topic list and the regex→handler map. New subscribers then just declare what they care
about.
Blocker to solve first
The two subscribers share the fe-team connection key, but
mqttService.createClient(key)destroys anyexisting client on that key — there's no "is anyone else using this key?" check:
So two subscribers on the same key tear each other down. Sharing the connection needs a
connectOrReuse-style entry point (name TBD) that reuses an existing client and tracks subscribers, soteardown only happens once the last one detaches. Opening a separate client per subscriber is the
fallback but wastes a connection.