ResourceUpdated sends a notification to all clients that have subscribed to the resource specified in params. This method is the primary way for a server author to signal that a resource has changed.
(ctx context.Context, params *ResourceUpdatedNotificationParams)
| 880 | // resource specified in params. This method is the primary way for a |
| 881 | // server author to signal that a resource has changed. |
| 882 | func (s *Server) ResourceUpdated(ctx context.Context, params *ResourceUpdatedNotificationParams) error { |
| 883 | s.mu.Lock() |
| 884 | subscribedSessions := s.resourceSubscriptions[params.URI] |
| 885 | sessions := slices.Collect(maps.Keys(subscribedSessions)) |
| 886 | s.mu.Unlock() |
| 887 | notifySessions(sessions, notificationResourceUpdated, params, s.opts.Logger) |
| 888 | s.opts.Logger.Info("resource updated notification sent", "uri", params.URI, "subscriber_count", len(sessions)) |
| 889 | return nil |
| 890 | } |
| 891 | |
| 892 | func (s *Server) subscribe(ctx context.Context, req *SubscribeRequest) (*emptyResult, error) { |
| 893 | if s.opts.SubscribeHandler == nil { |