refactor: Decouple grouping logic from core worker
This commit is contained in:
@@ -39,7 +39,8 @@ namespace Cryville.EEW.Unity {
|
|||||||
[SerializeField] EventGroupListView m_historyEventGroupList;
|
[SerializeField] EventGroupListView m_historyEventGroupList;
|
||||||
[SerializeField] GameObject m_connectingHint;
|
[SerializeField] GameObject m_connectingHint;
|
||||||
|
|
||||||
GroupingCoreWorker _worker;
|
CoreWorker _worker;
|
||||||
|
ReportGrouper _grouper;
|
||||||
CancellationTokenSource _cancellationTokenSource;
|
CancellationTokenSource _cancellationTokenSource;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
@@ -52,6 +53,7 @@ namespace Cryville.EEW.Unity {
|
|||||||
App.Init();
|
App.Init();
|
||||||
|
|
||||||
_worker = new(new TTSWorker());
|
_worker = new(new TTSWorker());
|
||||||
|
_grouper = new ReportGrouper();
|
||||||
_cancellationTokenSource = new();
|
_cancellationTokenSource = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +66,8 @@ namespace Cryville.EEW.Unity {
|
|||||||
_worker.TTSMessageGeneratorContext = SharedSettings.Instance;
|
_worker.TTSMessageGeneratorContext = SharedSettings.Instance;
|
||||||
_ongoingReportManager.Changed += OnOngoingReported;
|
_ongoingReportManager.Changed += OnOngoingReported;
|
||||||
_worker.Reported += OnReported;
|
_worker.Reported += OnReported;
|
||||||
_worker.GroupUpdated += OnGroupUpdated;
|
_grouper.GroupUpdated += OnGroupUpdated;
|
||||||
_worker.GroupRemoved += OnGroupRemoved;
|
_grouper.GroupRemoved += OnGroupRemoved;
|
||||||
Task.Run(() => GatewayVerify(_cancellationTokenSource.Token)).ContinueWith(task => {
|
Task.Run(() => GatewayVerify(_cancellationTokenSource.Token)).ContinueWith(task => {
|
||||||
if (task.IsFaulted) {
|
if (task.IsFaulted) {
|
||||||
OnReported(this, new() { Title = task.Exception.Message });
|
OnReported(this, new() { Title = task.Exception.Message });
|
||||||
@@ -189,6 +191,7 @@ namespace Cryville.EEW.Unity {
|
|||||||
void OnReported(object sender, ReportViewModel e) {
|
void OnReported(object sender, ReportViewModel e) {
|
||||||
if (e.Model is Exception && e.Model is not SourceWorkerNetworkException)
|
if (e.Model is Exception && e.Model is not SourceWorkerNetworkException)
|
||||||
Debug.LogError(e);
|
Debug.LogError(e);
|
||||||
|
_grouper.Report(e);
|
||||||
_ongoingReportManager.Report(e);
|
_ongoingReportManager.Report(e);
|
||||||
_uiActionQueue.Enqueue(() => {
|
_uiActionQueue.Enqueue(() => {
|
||||||
if (m_mapElementManager.OngoingCount == 0) {
|
if (m_mapElementManager.OngoingCount == 0) {
|
||||||
|
Reference in New Issue
Block a user