Add workspaces & persistent chats (#23)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2024-07-13 10:37:57 +02:00
1 parent 29263660fc
commit 59d0321625
43 files changed
+1392 -66

No files matched your search

@@ -64,4 +64,23 @@ public sealed class MessageBus
this.sendingSemaphore.Release();
}
}
public async Task<TResult?> SendMessageUseFirstResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data = default)
{
foreach (var (receiver, componentFilter) in this.componentFilters)
{
if (componentFilter.Length > 0 && sendingComponent is not null && !componentFilter.Contains(sendingComponent))
continue;
var eventFilter = this.componentEvents[receiver];
if (eventFilter.Length == 0 || eventFilter.Contains(triggeredEvent))
{
var result = await receiver.ProcessMessageWithResult<TPayload, TResult>(sendingComponent, triggeredEvent, data);
if (result is not null)
return (TResult) result;
}
}
return default;
}
}