addEvent method
void
addEvent(
- Map<String, dynamic> eventJson
)
Implementation
void addEvent(Map<String, dynamic> eventJson) {
// If the type is task-received, we need to add two events to the task
// data: the task-received event and the task-scheduled event.
if (eventJson['type'] == "task-received") {
CeleryEventSpawned eventSpawned = CeleryEventSpawned.fromJson(eventJson);
if (tasks[eventSpawned.uuid] == null) {
tasks[eventSpawned.uuid] = TaskData(taskId: eventSpawned.uuid);
}
tasks[eventSpawned.uuid]!.addEvent(eventSpawned);
if (eventJson["eta"] != null) {
CeleryEventScheduled eventScheduled =
CeleryEventScheduled.fromJson(eventJson);
if (tasks[eventScheduled.uuid] == null) {
tasks[eventScheduled.uuid] = TaskData(taskId: eventScheduled.uuid);
}
tasks[eventScheduled.uuid]!.addEvent(eventScheduled);
}
} else {
CeleryEventBase event = getCeleryEventFromJson(eventJson);
if (tasks[event.uuid] == null) {
tasks[event.uuid] = TaskData(taskId: event.uuid);
}
tasks[event.uuid]!.addEvent(event);
}
}