Beispiel #1
0
 private List <Task> BroadcastAsyncHere(IEnumerable <IPacket> packets, IBroadcastRule rule)
 {
     return(PlayerEntities.Select(s =>
                                  Task.Run(() =>
                                           rule == null || rule.Match(s.Value)
                 ? s.Value.Session.SendPacketsAsync(packets)
                 : Task.CompletedTask)).ToList());
 }
Beispiel #2
0
 public Task BroadcastAsync(IEnumerable <IPacket> packets, IBroadcastRule rule)
 {
     return(Task.WhenAll(PlayerEntities.Select(s =>
                                               Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.Session.SendPacketsAsync(packets) : Task.CompletedTask))));
 }
 public Task BroadcastAsync <T>(T packet, IBroadcastRule rule) where T : IPacket
 {
     lock (_locker)
     {
         return(Task.WhenAll(_players.Select(s => Task.Run(() => rule != null && rule.Match(s) ? s.SendPacketAsync(packet) : Task.CompletedTask))));
     }
 }
Beispiel #4
0
 public Task BroadcastAsync <T>(T packet, IBroadcastRule rule) where T : IPacket
 {
     return(Task.WhenAll(PlayerEntities.Select(s =>
                                               Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.Session.SendPacketAsync(packet) : Task.CompletedTask))));
 }
 public Task BroadcastAsync(IEnumerable <IPacket> packets, IBroadcastRule rule)
 {
     lock (_locker)
     {
         return(Task.WhenAll(_players.Select(s => Task.Run(() => rule != null && rule.Match(s) ? s.SendPacketsAsync(packets) : Task.CompletedTask))));
     }
 }