0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-21 18:55:17 +00:00

Broadcast with logs instead of dead

This commit is contained in:
Sanae 2022-02-09 15:59:47 -06:00
parent b0aa3dbf7b
commit 6771707dae

View file

@ -59,7 +59,10 @@ public class Server {
/// <param name="data">Memory owner to dispose once done</param>
/// <param name="sender">Optional sender to not broadcast data to</param>
public async Task Broadcast(IMemoryOwner<byte> data, Client? sender = null) {
await Task.WhenAll(Clients.Where(c => c.Connected && c != sender).Select(client => client.Send(data.Memory)));
await Task.WhenAll(Clients.Where(c => c.Connected && c != sender).Select(client => {
Logger.Info($"Sending {(PacketType) data.Memory.Span[16]} to {client.Id} from {sender.Id}");
return client.Send(data.Memory);
}));
data.Dispose();
}