mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
wire pub/sub channel subscriptions into channel_focus handler
When a client focuses a channel, subscribe to its pub/sub topic. When switching channels, unsubscribe from the old topic first. This completes the pub/sub integration — channel broadcasts now route only to clients subscribed to the relevant topic. https://claude.ai/code/session_01CBFF3r84ywkJRWwuqw8zD8
This commit is contained in:
@@ -94,9 +94,15 @@ func (p *LiveKitProcess) SetProcessStoppedForTest() {
|
||||
func NewHubForTest() *Hub {
|
||||
return &Hub{
|
||||
clients: make(map[int64]*Client),
|
||||
pubsub: NewPubSub(),
|
||||
}
|
||||
}
|
||||
|
||||
// PubSubForTest exposes the hub's PubSub for external tests.
|
||||
func (h *Hub) PubSubForTest() *PubSub {
|
||||
return h.pubsub
|
||||
}
|
||||
|
||||
// BuildAuthOKForTest exposes Hub.buildAuthOK for external tests.
|
||||
func (h *Hub) BuildAuthOKForTest(user *db.User, roleName string) []byte {
|
||||
return h.buildAuthOK(user, roleName)
|
||||
|
||||
@@ -160,9 +160,20 @@ func (h *Hub) handleMessage(c *Client, raw []byte) {
|
||||
}
|
||||
// Apply client state mutations.
|
||||
if result.SetChannelID != nil {
|
||||
oldChID := c.getChannelID()
|
||||
c.mu.Lock()
|
||||
c.channelID = *result.SetChannelID
|
||||
c.mu.Unlock()
|
||||
// Update pub/sub channel topic subscriptions.
|
||||
newChID := *result.SetChannelID
|
||||
if oldChID != newChID {
|
||||
if oldChID > 0 {
|
||||
c.hub.pubsub.Unsubscribe(c, ChannelTopic(oldChID))
|
||||
}
|
||||
if newChID > 0 {
|
||||
c.hub.pubsub.Subscribe(c, ChannelTopic(newChID))
|
||||
}
|
||||
}
|
||||
}
|
||||
if result.SetE2EEPubKey != nil {
|
||||
c.setE2EEPubKey(*result.SetE2EEPubKey)
|
||||
|
||||
Reference in New Issue
Block a user