Exemplo n.º 1
0
        private async Task Process()
        {
            var stopwatch = new Stopwatch();

            while (!_cancellationToken.IsCancellationRequested)
            {
                stopwatch.Restart();
                Dictionary <RegionCoordinates, HashSet <RegionUpdateMessage> > encodes = new(), updates = new();

                foreach (var player in Players)
                {
                    try
                    {
                        await _playerUpdater.PreUpdateAsync(player, encodes, updates);

                        await _playerUpdater.UpdateAsync(player);

                        await _playerUpdater.PostUpdateAsync(player);
                    }
                    catch (Exception e)
                    {
                        Log.Logger.Error(e, nameof(Process));
                    }
                }
                var deltaSleep = 600 - (int)stopwatch.Elapsed.TotalMilliseconds;
                if (deltaSleep > 0)
                {
                    await Task.Delay(deltaSleep, _cancellationToken);
                }
            }
        }
Exemplo n.º 2
0
        private async Task Process()
        {
            var stopwatch = new Stopwatch();

            while (!_cancellationToken.IsCancellationRequested)
            {
                stopwatch.Restart();
                Dictionary <RegionCoordinates, HashSet <RegionUpdateMessage> > encodes = new(), updates = new();
                for (int playerId = _playerEntityList.Entities.Length - 1; playerId >= 0; playerId--)
                {
                    Player player = _playerEntityList.Entities[playerId];
                    if (player == null || !player.IsActive)
                    {
                        continue;
                    }
                    try
                    {
                        await _playerUpdater.PreUpdateAsync(player, encodes, updates);

                        await _playerUpdater.UpdateAsync(player);

                        await _playerUpdater.PostUpdateAsync(player).ConfigureAwait(false);
                    }
                    catch (Exception e)
                    {
                        Log.Logger.Error(e, nameof(Process));
                    }
                }

                var deltaSleep = 600 - (int)stopwatch.Elapsed.TotalMilliseconds;
                if (deltaSleep > 0)
                {
                    await Task.Delay(deltaSleep, _cancellationToken).ConfigureAwait(false);
                }
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Order> > Put(int id, [FromBody] OrderQuantityBindingModel model)
        {
            var entity = await _updater.UpdateAsync(id, model);

            return(Ok(entity));
        }