예제 #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);
                }
            });
        }
예제 #2
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);
        }