Skip to content

Split live-status tracking into its own subscriber (and share one MQTT connection) #7608

Description

@n-lark

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions