add BroadcastAsync

This commit is contained in:
RaidMax 2022-03-23 11:43:20 -05:00
parent 63b04be4c7
commit 51ef67ae9c
2 changed files with 21 additions and 2 deletions

View File

@ -177,7 +177,7 @@ namespace SharedLibraryCore.Database.Models
return e;
}
[Obsolete]
[Obsolete("Use TellAsync")]
public void Tell(IEnumerable<string> messages)
{
foreach (var message in messages)
@ -192,6 +192,11 @@ namespace SharedLibraryCore.Database.Models
{
foreach (var message in messages)
{
if (token.IsCancellationRequested)
{
return;
}
await Tell(message).WaitAsync(Utilities.DefaultCommandTimeout, token);
}
}

View File

@ -238,6 +238,7 @@ namespace SharedLibraryCore
return e;
}
[Obsolete("Use BroadcastAsync")]
public void Broadcast(IEnumerable<string> messages, EFClient sender = null)
{
foreach (var message in messages)
@ -248,6 +249,19 @@ namespace SharedLibraryCore
}
}
public async Task BroadcastAsync(IEnumerable<string> messages, EFClient sender = null,
CancellationToken token = default)
{
foreach (var message in messages)
{
if (Manager.CancellationToken.IsCancellationRequested)
{
return;
}
await Broadcast(message, sender).WaitAsync(Utilities.DefaultCommandTimeout, Manager.CancellationToken);
}
}
/// <summary>
/// Send a message to a particular players