add local daemon socket protocol
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user