changeAndNotify is called when a feature is added or removed. It calls change, which should do the work and report whether a change actually occurred. If there was a change, it notifies a snapshot of the sessions.
(c *Client, notification string, params P, change func() bool)
| 432 | // It calls change, which should do the work and report whether a change actually occurred. |
| 433 | // If there was a change, it notifies a snapshot of the sessions. |
| 434 | func changeAndNotify[P Params](c *Client, notification string, params P, change func() bool) { |
| 435 | var sessions []*ClientSession |
| 436 | // Lock for the change, but not for the notification. |
| 437 | c.mu.Lock() |
| 438 | if change() { |
| 439 | // Check if listChanged is enabled for this notification type. |
| 440 | if c.shouldSendListChangedNotification(notification) { |
| 441 | sessions = slices.Clone(c.sessions) |
| 442 | } |
| 443 | } |
| 444 | c.mu.Unlock() |
| 445 | notifySessions(sessions, notification, params, c.opts.Logger) |
| 446 | } |
| 447 | |
| 448 | // shouldSendListChangedNotification checks if the client's capabilities allow |
| 449 | // sending the given list-changed notification. |
no test coverage detected
searching dependent graphs…