add BroadcastAsync
This commit is contained in:
parent
63b04be4c7
commit
51ef67ae9c
@ -177,7 +177,7 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
[Obsolete("Use TellAsync")]
|
||||||
public void Tell(IEnumerable<string> messages)
|
public void Tell(IEnumerable<string> messages)
|
||||||
{
|
{
|
||||||
foreach (var message in messages)
|
foreach (var message in messages)
|
||||||
@ -188,10 +188,15 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task TellAsync(IEnumerable<string> messages, CancellationToken token =default)
|
public async Task TellAsync(IEnumerable<string> messages, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
foreach (var message in messages)
|
foreach (var message in messages)
|
||||||
{
|
{
|
||||||
|
if (token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await Tell(message).WaitAsync(Utilities.DefaultCommandTimeout, token);
|
await Tell(message).WaitAsync(Utilities.DefaultCommandTimeout, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,7 @@ namespace SharedLibraryCore
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use BroadcastAsync")]
|
||||||
public void Broadcast(IEnumerable<string> messages, EFClient sender = null)
|
public void Broadcast(IEnumerable<string> messages, EFClient sender = null)
|
||||||
{
|
{
|
||||||
foreach (var message in messages)
|
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>
|
/// <summary>
|
||||||
/// Send a message to a particular players
|
/// Send a message to a particular players
|
||||||
|
Loading…
Reference in New Issue
Block a user