Ejemplo n.º 1
0
        private bool Process()
        {
            if (!_dispatchService.GetIsGrimDawnRunning)
            {
                return(false);
            }

            int count = 0;

            {
                var items = _playerItemDao.ListMissingReplica(300);
                count += items.Count;
                foreach (var item in items)
                {
                    var hash = GetHash(item);
                    if (_cache.Exists(hash)) // Don't ask for the same item twice. Esp if the user somehow gets two identical items in, this would infinitely loop.
                    {
                        continue;
                    }


                    List <byte> buffer = Serialize(item);
                    if (!_dispatchService.DispatchItemSeedInfoRequest(buffer))
                    {
                        return(false); //
                    }
                    _cache.Add(hash);
                    Thread.Sleep(1);
                }
            }

            {
                var items = _buddyItemDao.ListMissingReplica(300);
                count += items.Count;

                foreach (var item in items)
                {
                    var hash = GetHash(item);
                    if (_cache.Exists(hash)) // Don't ask for the same item twice. Esp if the user somehow gets two identical items in, this would infinitely loop.
                    {
                        continue;
                    }


                    List <byte> buffer = Serialize(item);
                    if (!_dispatchService.DispatchItemSeedInfoRequest(buffer))
                    {
                        return(false);
                    }

                    _cache.Add(hash);
                    Thread.Sleep(1);
                }
            }

            return(count > 0);
        }
Ejemplo n.º 2
0
 public IList <PlayerItem> ListMissingReplica(int limit)
 {
     return(ThreadExecuter.Execute(
                () => _repo.ListMissingReplica(limit)
                ));
 }