add local daemon socket protocol

This commit is contained in:
2026-05-27 13:55:38 +01:00
parent c56de27f44
commit d07a09d64f
6 changed files with 709 additions and 3 deletions

View File

@@ -153,6 +153,24 @@ func (s *Session) Unsubscribe(l ChildEventListener) {
s.listeners.Store(&next)
}
// UnsubscribeClient removes a previously-registered network client listener.
// Safe to call with a listener that was never registered.
func (s *Session) UnsubscribeClient(l ChildEventListener) {
s.clientListenersMu.Lock()
defer s.clientListenersMu.Unlock()
prev := s.clientListenersSnapshot()
if len(prev) == 0 {
return
}
next := make([]ChildEventListener, 0, len(prev))
for _, e := range prev {
if e != l {
next = append(next, e)
}
}
s.clientListeners.Store(&next)
}
// listenersSnapshot returns the frozen listener slice. Safe to call
// without the listeners mutex.
func (s *Session) listenersSnapshot() []ChildEventListener {