fromJson static method
Implementation
static Event? fromJson(Map<String, dynamic> json) {
final eventAction = json['action'];
if (eventAction == null) return null;
switch (EventAction.fromJson(eventAction)) {
case EventAction.callStateUpdated:
return Event.callStateUpdated(stateData: CallStateData.fromJson(json));
case EventAction.inputsUpdated:
return Event.inputsUpdated(inputs: InputSettings.fromJson(json['inputs']));
case EventAction.publishingUpdated:
return Event.publishingUpdated(publishing: PublishingSettings.fromJson(json['publishing']));
case EventAction.participantJoined:
return Event.participantJoined(participant: Participant.fromJson(json['participant']));
case EventAction.participantUpdated:
return Event.participantUpdated(participant: Participant.fromJson(json['participant']));
case EventAction.participantLeft:
return Event.participantLeft(participant: Participant.fromJson(json['participant']));
case EventAction.activeSpeakerChanged:
final participant = json['participant'];
return Event.activeSpeakerChanged(participant: participant == null ? null : Participant.fromJson(participant));
case EventAction.subscriptionsUpdated:
return Event.subscriptionsUpdated(
// ignore: avoid_as
subscriptions: (json['subscriptions'] as Map<String, dynamic>)
.map((key, value) => MapEntry(ParticipantId.fromJson(key), SubscriptionSettings.fromJson(value))),
);
case EventAction.subscriptionProfilesUpdated:
return Event.subscriptionProfilesUpdated(
// ignore: avoid_as
profiles: (json['profiles'] as Map<String, dynamic>).map(
(key, value) => MapEntry(
SubscriptionProfile.fromJson(key),
MediaSubscriptionSettings.fromJson(value),
),
),
);
case EventAction.participantCountsUpdated:
return Event.participantCountsUpdated(counts: ParticipantCounts.fromJson(json));
case EventAction.availableDevicesUpdated:
return Event.availableDevicesUpdated(availableDevices: Devices.fromJson(json));
case EventAction.appMessageReceived:
// ignore: avoid_dynamic_calls
return Event.appMessageReceived(data: jsonEncode(json['msgData']), from: ParticipantId(json['from']));
case EventAction.recordingStarted:
return Event.recordingStarted(status: RecordingStatus.fromJson(json['status']));
case EventAction.recordingStopped:
return Event.recordingStopped(streamId: StreamId.fromJson(json['streamId']));
case EventAction.recordingError:
return Event.recordingError(streamId: StreamId.fromJson(json['streamId']), message: json['message']);
case EventAction.liveStreamStarted:
return Event.liveStreamStarted(status: LiveStreamStatus.fromJson(json['status']));
case EventAction.liveStreamStopped:
return Event.liveStreamStopped(streamId: StreamId.fromJson(json['streamId']));
case EventAction.liveStreamWarning:
return Event.liveStreamWarning(streamId: StreamId.fromJson(json['streamId']), message: json['message']);
case EventAction.liveStreamError:
return Event.liveStreamError(streamId: StreamId.fromJson(json['streamId']), message: json['message']);
case EventAction.networkStatsUpdated:
return Event.networkStatsUpdated(stats: NetworkStats.fromJson(json));
case EventAction.error:
return Event.error(message: json['message']);
}
}