ServerNotification.fromJson constructor

ServerNotification.fromJson(
  1. Map<String, Object?> json
)

Reads the branch json names; an unrecognised one is kept as UnknownServerNotification.

Implementation

factory ServerNotification.fromJson(Map<String, Object?> json) {
  switch (json['method']) {
    case 'notifications/cancelled':
      return CancelledNotification.fromJson(json);
    case 'notifications/progress':
      return ProgressNotification.fromJson(json);
    case 'notifications/resources/list_changed':
      return ResourceListChangedNotification.fromJson(json);
    case 'notifications/resources/updated':
      return ResourceUpdatedNotification.fromJson(json);
    case 'notifications/prompts/list_changed':
      return PromptListChangedNotification.fromJson(json);
    case 'notifications/tools/list_changed':
      return ToolListChangedNotification.fromJson(json);
    case 'notifications/message':
      return LoggingMessageNotification.fromJson(json);
    case 'notifications/tasks/status':
      return TaskStatusNotification.fromJson(json);
    case 'notifications/tasks':
      return TaskStatusNotification.fromJson(json);
    case 'notifications/elicitation/complete':
      return ElicitationCompleteNotification.fromJson(json);
    case 'notifications/subscriptions/acknowledged':
      return SubscriptionsAcknowledgedNotification.fromJson(json);
  }
  return UnknownServerNotification.fromJson(json);
}