Beispiel #1
0
        /// <summary>
        /// Sets base table data such as <see cref="GameFormat"/>, <see cref="GameType"/>, <see cref="GameLimit"/>
        /// </summary>
        private void SetBaseTableData()
        {
            if (isConnectedInfoParsed)
            {
                return;
            }

            var infoImporter = importerService.GetRunningImporter <IIgnitionInfoImporter>();

            if (infoImporter != null && infoImporter.InfoDataManager != null)
            {
                IgnitionTableData tableData = null;

                tableData = infoImporter.InfoDataManager.GetTableData(TableId);

                if (tableData == null)
                {
                    return;
                }

                TableId    = tableData.Id;
                MaxSeat    = tableData.TableSize;
                GameFormat = tableData.GameFormat;
                GameLimit  = tableData.GameLimit;
                GameType   = tableData.GameType;
                TableName  = HttpUtility.UrlDecode(tableData.TableName);

                isConnectedInfoParsed = true;

                LogProvider.Log.Info(this, $"Table info has been set: {tableData} [{Identifier}]");
            }
        }
Beispiel #2
0
        private void ProcessZoneData(string url, string data)
        {
            try
            {
                data = data.Remove(0, url.Length).Trim();

                var zoneTableInfoList = JsonConvert.DeserializeObject <IEnumerable <ZoneTableInfo> >(data);

                rwLock.EnterUpgradeableReadLock();

                try
                {
                    foreach (var zoneTableInfo in zoneTableInfoList)
                    {
                        if (tableData.ContainsKey(zoneTableInfo.gameId))
                        {
                            continue;
                        }

                        if (!rwLock.IsWriteLockHeld)
                        {
                            rwLock.EnterWriteLock();
                        }

                        var table = new IgnitionTableData
                        {
                            Id         = zoneTableInfo.gameId,
                            TableName  = zoneTableInfo.gameName,
                            IsZone     = true,
                            TableSize  = zoneTableInfo.seats,
                            GameType   = BovadaConverters.ConvertGameType(zoneTableInfo.gameType),
                            GameLimit  = BovadaConverters.ConvertGameLimit(zoneTableInfo.limit),
                            GameFormat = GameFormat.Zone
                        };

                        tableData.Add(zoneTableInfo.gameId, table);
                    }
                }
                finally
                {
                    if (rwLock.IsWriteLockHeld)
                    {
                        rwLock.ExitWriteLock();
                    }

                    rwLock.ExitUpgradeableReadLock();
                }
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, $"Zone info could not be processed {site}", e);
            }
        }
Beispiel #3
0
        private void ProcessCashData(string url, string data)
        {
            try
            {
                var uri = new Uri(url);
                var parsedQueryString = HttpUtility.ParseQueryString(uri.Query);
                var tableSeatsText    = parsedQueryString.Get("tableSeats");
                var limitText         = parsedQueryString.Get("limitType");
                var gameTypeText      = parsedQueryString.Get("gameType");

                if (string.IsNullOrWhiteSpace(data))
                {
                    LogProvider.Log.Warn("CashData was empty.");
                    return;
                }

                var tableText = ReadJsonData(data, "table");

                uint tableId;

                if (!uint.TryParse(tableText, out tableId))
                {
                    if (isLoggingEnabled)
                    {
                        LogProvider.Log.Error(this, $"Table id couldn't be parsed from: {tableText} [{data}]");
                    }

                    return;
                }

                int tableSize;

                if (!int.TryParse(tableSeatsText, out tableSize))
                {
                    if (isLoggingEnabled)
                    {
                        LogProvider.Log.Error(this, $"Table size couldn't be parsed from: {tableSeatsText} [{data}].");
                    }

                    return;
                }

                rwLock.EnterUpgradeableReadLock();

                try
                {
                    if (tableData.ContainsKey(tableId))
                    {
                        return;
                    }

                    rwLock.EnterWriteLock();

                    try
                    {
                        var table = new IgnitionTableData
                        {
                            Id         = tableId,
                            TableSize  = tableSize,
                            GameFormat = GameFormat.Cash,
                            GameLimit  = BovadaConverters.ConvertGameLimit(limitText),
                            GameType   = BovadaConverters.ConvertGameType(gameTypeText)
                        };

                        tableData.Add(tableId, table);
                        LogProvider.Log.Info($"Table info has been read from client: {table} [{site}]");
                    }
                    finally
                    {
                        rwLock.ExitWriteLock();
                    }
                }
                finally
                {
                    rwLock.ExitUpgradeableReadLock();
                }
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, $"Cash info could not be processed {site}", e);
            }
        }
Beispiel #4
0
        private void ProcessTournamentData(string url, string data)
        {
            try
            {
                var tournLastIndex = url.LastIndexOf("/");
                var tournFistIndex = url.LastIndexOf("/", tournLastIndex - 1) + 1;
                var tournamentText = url.Substring(tournFistIndex, tournLastIndex - tournFistIndex);

                uint tounamentId;

                if (!uint.TryParse(tournamentText, out tounamentId))
                {
                    if (isLoggingEnabled)
                    {
                        LogProvider.Log.Error(this, $"Tournament id couldn't be parsed from: {tournamentText}");
                    }

                    return;
                }

                var seatText       = ReadJsonData(data, "\"seats\"");
                var maxPlayersText = ReadJsonData(data, "maxPlayers");
                var limitText      = ReadJsonTextData(data, "limit");
                var gameTypeText   = ReadJsonTextData(data, "gameType");
                var tournamentName = ReadJsonTextData(data, "tournamentName");

                if (string.IsNullOrEmpty(seatText) && string.IsNullOrEmpty(maxPlayersText))
                {
                    if (isLoggingEnabled)
                    {
                        LogProvider.Log.Warn(this, $"Seat and max players data hasn't been found.");
                    }

                    return;
                }

                int seat;

                if (!int.TryParse(seatText, out seat))
                {
                    if (isLoggingEnabled)
                    {
                        LogProvider.Log.Error(this, $"Seat couldn't be parsed from: {seatText}");
                    }

                    return;
                }

                int maxPlayers;

                if (!int.TryParse(maxPlayersText, out maxPlayers) && isLoggingEnabled)
                {
                    LogProvider.Log.Error(this, $"Max players couldn't be parsed from: {maxPlayersText}");
                }

                var gameLimit = BovadaConverters.ConvertGameLimit(limitText);

                var table = new IgnitionTableData
                {
                    Id         = tounamentId,
                    TableSize  = seat,
                    GameFormat = maxPlayers > seat ? GameFormat.MTT : GameFormat.SnG,
                    GameLimit  = gameLimit,
                    GameType   = BovadaConverters.ConvertGameType(gameTypeText),
                    TableName  = tournamentName
                };

                rwLock.EnterUpgradeableReadLock();

                try
                {
                    if (tableData.ContainsKey(tounamentId))
                    {
                        return;
                    }

                    rwLock.EnterWriteLock();

                    try
                    {
                        tableData.Add(tounamentId, table);
                        LogProvider.Log.Info(this, $"Tournament table info has been read from client: {table} [{site}]");
                    }
                    finally
                    {
                        rwLock.ExitWriteLock();
                    }
                }
                finally
                {
                    rwLock.ExitUpgradeableReadLock();
                }
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, $"Tournament info could not be processed {site}", e);
            }
        }