Exemplo n.º 1
0
        public void TableChanged(int tableId, IPlayTableService playTableService)
        {
            var tablePlayers = playTableService.GetPlayersOfTable(tableId);
            var tableViewers = playTableService.GetTableViewer(tableId);
            var tableState   = TableHubUtils.GetTableState(tableId, playTableService, _mapper);

            Parallel.ForEach(tablePlayers, (tablePlayer) =>
            {
                var clientUser = getClientUser(tablePlayer.PlayerId);
                if (clientUser != null)
                {
                    clientUser.PlayerTableState(tableState);
                }
            });

            // for all viewers of the table
            Parallel.ForEach(tableViewers, (tableViewer) =>
            {
                var clientUser = getClientUser(tableViewer.userId);
                if (clientUser != null)
                {
                    clientUser.SpectatorTable(tableState);
                }
            });
        }
Exemplo n.º 2
0
        public async Task PlayerCards()
        {
            int userId;

            TryParsUserId(out userId);
            var cards = TableHubUtils.GetPlayerCards(userId, _tablesService);
            await Clients.User(userId.ToString()).PlayerCards(cards);
        }
Exemplo n.º 3
0
        public void OnSpectatorStateChanged(int userId, IPlayTableService playTableService)
        {
            var clientUser = getClientUser(userId);

            if (clientUser != null)
            {
                clientUser.SpectatorState(TableHubUtils.GetViewWerModel(userId, playTableService, _mapper));
            }
        }
Exemplo n.º 4
0
        public async Task SpectatorState()
        {
            int userId;

            if (TryParsUserId(out userId))
            {
                await Clients.User(userId.ToString()).SpectatorState(TableHubUtils.GetViewWerModel(userId, _tablesService, _mapper));
            }
        }
Exemplo n.º 5
0
        public async Task PlayerCardsForSpectator()
        {
            int userId;

            TryParsUserId(out userId);

            //for viewers
            var viewer = _tablesService.GetTableViewerByUserId(userId);
            var cards  = TableHubUtils.GetPlayerCards(viewer.SeePlayerCard, _tablesService);
            await Clients.User(userId.ToString()).PlayerCardsForSpectator(cards);
        }
Exemplo n.º 6
0
        public async Task SpectatorTable()
        {
            int userId;
            PlayTableStaeModel state = null;

            if (TryParsUserId(out userId))
            {
                var viewer = _tablesService.GetTableViewerByUserId(userId);
                if (viewer != null)
                {
                    state = TableHubUtils.GetTableState(viewer.tableId, _tablesService, _mapper);
                }
            }
            await Clients.User(Context.UserIdentifier).SpectatorTable(state);
        }
Exemplo n.º 7
0
        public Task UpdatePlayerTableState(int playerId = -1)
        {
            if (playerId < 0)
            {
                string userId = Context.UserIdentifier;
            }
            PlayTableStaeModel modelValue = null;

            if (TryParsUserId(out playerId))
            {
                if (playerId > 0)
                {
                    modelValue = TableHubUtils.GetTablePLayerState(playerId, _tablesService, _mapper);
                    return(Clients.User(playerId.ToString()).PlayerTableState(modelValue));
                }
            }
            return(Task.FromResult <PlayTableStaeModel>(null));
        }
Exemplo n.º 8
0
 public async void TableListChanged(IPlayTableService playTableService)
 {
     await _hub.Clients.All.Tables(TableHubUtils.GetTablesWithUserCount(playTableService, _mapper));
 }
Exemplo n.º 9
0
 public async Task Tables()
 {
     await Clients.All.Tables(TableHubUtils.GetTablesWithUserCount(_tablesService, _mapper));
 }