Beispiel #1
0
        protected override void Init()
        {
            Rankings = new DedimaniaRanking[] {};
            Settings = DedimaniaSettings.ReadFromFile(PluginSettingsFilePath);

            InitializeDedimaniaClient();

            AuthResult authResult = TryAuthentication();

            if (authResult == AuthResult.Failed)
            {
                return;
            }

            IsDedimaniaResponsive = (authResult == AuthResult.Success);

            InitializePlugins();
            ResetUpdateServerPlayersTimer();

            DedimaniaClient.Url = Settings.ReportUrl;

            if (IsDedimaniaResponsive)
            {
                ReportCurrentChallenge(GetExistingCurrentRankings(), GetCurrentChallengeInfoCached());
            }
            else
            {
                OnRankingsChanged(new DedimaniaRanking[] {});
            }

            Context.RPCClient.Callbacks.BeginRace    += Callbacks_BeginRace;
            Context.RPCClient.Callbacks.EndRace      += Callbacks_EndRace;
            Context.RPCClient.Callbacks.PlayerFinish += Callbacks_PlayerFinish;
        }
Beispiel #2
0
        public static DedimaniaSettings ReadFromFile(string xmlConfigurationFile)
        {
            DedimaniaSettings result         = new DedimaniaSettings();
            XDocument         configDocument = XDocument.Load(xmlConfigurationFile);

            if (configDocument.Root == null)
            {
                throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile);
            }

            result.AuthUrl   = ReadConfigString(configDocument.Root, "AuthUrl", AUTH_URL, xmlConfigurationFile);
            result.ReportUrl = ReadConfigString(configDocument.Root, "ReportUrl", REPORT_URL, xmlConfigurationFile);
            result.Plugins   = PluginConfigEntryCollection.ReadFromDirectory(Path.GetDirectoryName(xmlConfigurationFile));

            return(result);
        }