EventResult.fromJson constructor

EventResult.fromJson(
  1. JSONMap json
)

Implementation

factory EventResult.fromJson(JSONMap json) {
  final JSONMap result = json['params'] ?? {};
  switch (json['cmd']) {
    case 'setSiteInfo':
      return EventResult(
        type: EventType.setSiteInfo,
        siteInfo: SiteInfo.fromJson(result),
      );
    case 'setServerInfo':
      return EventResult(
        type: EventType.setServerInfo,
        serverInfo: ServerInfo.fromJson(result),
      );
    case 'setAnnouncerInfo':
      return EventResult(
        type: EventType.setAnnouncerInfo,
        result: result,
      );
    default:
      return EventResult(
        type: EventType.unknown,
        result: json,
      );
  }
}