public void HandleGameData(object sender, GameDataReceivedEventArgs e)
        {
            var jsonString = e.Json.ToString();

            // Ensure it's CS:GO JSON
            if (!jsonString.Contains("Counter-Strike: Global Offensive"))
            {
                return;
            }

            // Parse the JSON
            try
            {
                if (DataModel == null)
                {
                    DataModel = new CounterStrikeDataModel();
                }
                JsonConvert.PopulateObject(jsonString, DataModel, new JsonSerializerSettings {
                    Error = HandleGameDataError
                });
            }
            catch (Exception ex)
            {
                Logger?.Error(ex, "Failed to deserialize CS:GO JSON");
                throw;
            }
        }
        public CounterStrikeModel(DeviceManager deviceManager, LuaManager luaManager, MetroDialogService dialogService,
                                  GameStateWebServer gameStateWebServer) : base(deviceManager, luaManager)
        {
            _gameStateWebServer = gameStateWebServer;
            _dialogService      = dialogService;

            Settings  = SettingsProvider.Load <CounterStrikeSettings>();
            DataModel = new CounterStrikeDataModel();
            ProcessNames.Add("csgo");

            FindGameDir();
            PlaceConfigFile();
        }
Example #3
0
        public void HandleGameData(object sender, GameDataReceivedEventArgs e)
        {
            var jsonString = e.Json.ToString();

            // Ensure it's CS:GO JSON
            if (!jsonString.Contains("Counter-Strike: Global Offensive"))
                return;

            // Parse the JSON
            try
            {
                if (DataModel == null)
                    DataModel = new CounterStrikeDataModel();
                JsonConvert.PopulateObject(jsonString, DataModel);
            }
            catch (Exception ex)
            {
                Logger?.Error(ex, "Failed to deserialize CS:GO JSON");
                throw;
            }
        }