Пример #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());
 }
Пример #2
0
        private List <Task> BroadcastEventAsyncHere(ILogicEvent logicEvent, IBroadcastEventRule rule, bool onlyPlayers)
        {
            if (onlyPlayers)
            {
                return(PlayerEntities.Select(s =>
                                             Task.Run(() =>
                                                      rule == null || rule.Match(s.Value)
                            ? s.Value.EmitEventAsync(logicEvent)
                            : Task.CompletedTask)).ToList());
            }

            return(SubstantialEntities.Select(s =>
                                              Task.Run(() =>
                                                       rule == null || rule.Match(s.Value)
                        ? s.Value.EmitEventAsync(logicEvent)
                        : Task.CompletedTask)).ToList());
        }
Пример #3
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))));
 }
Пример #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))));
 }