Ejemplo n.º 1
0
        private async Task SendGameViewUpdateAsync(IEnumerable <string> userIds, GameView gameView)
        {
            await _GameViewDictionarySemaphore.WaitAsync();

            try
            {
                foreach (var userId in userIds)
                {
                    if (!string.IsNullOrEmpty(userId))
                    {
                        var clonedGameView = gameView.Clone() as GameView;

                        if (_PlayerDictionary.TryGetValue(userId, out var role))
                        {
                            clonedGameView.GameRole = role;

                            _GameViewDictionary[userId] = clonedGameView;

                            if (GameViewUpdatedAsyncCallback != null)
                            {
                                await GameViewUpdatedAsyncCallback(_Game.GameId, userId, clonedGameView).ConfigureAwait(false);
                            }
                        }
                    }
                }
            }
            finally
            {
                _GameViewDictionarySemaphore.Release();
            }
        }