Beispiel #1
0
        public ActionResult RestartGossipServer()
        {
            IEnumerable <WebSocket> gossipServers = LiveCache.GetAll <WebSocket>();

            foreach (WebSocket server in gossipServers)
            {
                server.Abort();
            }

            IGossipConfig   gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));
            Func <Member[]> playerList   = () => LiveCache.GetAll <IPlayer>()
                                           .Where(player => player.Descriptor != null && player.Template <IPlayerTemplate>().Account.Config.GossipSubscriber)
                                           .Select(player => new Member()
            {
                Name           = player.AccountHandle,
                WriteTo        = (message) => player.WriteTo(new string[] { message }),
                BlockedMembers = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => !acq.IsFriend).Select(acq => acq.PersonHandle),
                Friends        = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => acq.IsFriend).Select(acq => acq.PersonHandle)
            }).ToArray();

            void exceptionLogger(Exception ex) => LoggingUtility.LogError(ex);
            void activityLogger(string message) => LoggingUtility.Log(message, LogChannels.GossipServer);

            GossipClient gossipServer = new GossipClient(gossipConfig, exceptionLogger, activityLogger, playerList);

            Task.Run(() => gossipServer.Launch());

            LiveCache.Add(gossipServer, "GossipWebClient");

            return(RedirectToAction("Index", new { Message = "Gossip Server Restarted" }));
        }
Beispiel #2
0
        public ActionResult GossipConfig(DashboardViewModel vModel)
        {
            ApplicationUser authedUser   = UserManager.FindById(User.Identity.GetUserId());
            IGossipConfig   gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));

            gossipConfig.GossipActive             = vModel.GossipActive;
            gossipConfig.ClientId                 = vModel.ClientId;
            gossipConfig.ClientName               = vModel.ClientName;
            gossipConfig.ClientSecret             = vModel.ClientSecret;
            gossipConfig.SuspendMultiplierMaximum = vModel.SuspendMultiplierMaximum;
            gossipConfig.SuspendMultiplier        = vModel.SuspendMultiplier;
            gossipConfig.SupportedChannels        = vModel.SupportedChannels;
            gossipConfig.SupportedFeatures        = vModel.SupportedFeatures;

            string message;

            if (gossipConfig.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - EditGossipConfig[" + gossipConfig.UniqueKey.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Beispiel #3
0
        //Also called Dashboard in most of the html
        public ActionResult Index()
        {
            IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld));
            IGossipConfig gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));

            DashboardViewModel dashboardModel = new DashboardViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId()),

                Inanimates = TemplateCache.GetAll <IInanimateTemplate>(),
                NPCs       = TemplateCache.GetAll <INonPlayerCharacterTemplate>(),
                Zones      = TemplateCache.GetAll <IZoneTemplate>(),
                Worlds     = TemplateCache.GetAll <IGaiaTemplate>(),
                Locales    = TemplateCache.GetAll <ILocaleTemplate>(),
                Rooms      = TemplateCache.GetAll <IRoomTemplate>(),

                HelpFiles         = TemplateCache.GetAll <IHelp>(),
                Races             = TemplateCache.GetAll <IRace>(),
                Celestials        = TemplateCache.GetAll <ICelestial>(),
                Journals          = TemplateCache.GetAll <IJournalEntry>(),
                DimensionalModels = TemplateCache.GetAll <IDimensionalModelData>(),
                Flora             = TemplateCache.GetAll <IFlora>(),
                Fauna             = TemplateCache.GetAll <IFauna>(),
                Minerals          = TemplateCache.GetAll <IMineral>(),
                Materials         = TemplateCache.GetAll <IMaterial>(),
                DictionaryWords   = ConfigDataCache.GetAll <ILexeme>(),
                Languages         = ConfigDataCache.GetAll <ILanguage>(),
                Genders           = TemplateCache.GetAll <IGender>(),
                UIModules         = ConfigDataCache.GetAll <IUIModule>(),
                FightingArts      = TemplateCache.GetAll <IFightingArt>(),

                LiveTaskTokens = Processor.GetAllLiveTaskStatusTokens(),
                LivePlayers    = LiveCache.GetAll <IPlayer>().Count(),
                LiveInanimates = LiveCache.GetAll <IInanimate>().Count(),
                LiveNPCs       = LiveCache.GetAll <INonPlayerCharacter>().Count(),
                LiveZones      = LiveCache.GetAll <IZone>().Count(),
                LiveWorlds     = LiveCache.GetAll <IGaia>().Count(),
                LiveLocales    = LiveCache.GetAll <ILocale>().Count(),
                LiveRooms      = LiveCache.GetAll <IRoom>().Count(),

                ConfigDataObject      = globalConfig,
                WebsocketPortalActive = globalConfig.WebsocketPortalActive,
                AdminsOnly            = globalConfig.AdminsOnly,
                UserCreationActive    = globalConfig.UserCreationActive,
                BaseLanguage          = globalConfig.BaseLanguage,
                AzureTranslationKey   = globalConfig.AzureTranslationKey,
                TranslationActive     = globalConfig.TranslationActive,
                DeepLexActive         = globalConfig.DeepLexActive,
                MirriamDictionaryKey  = globalConfig.MirriamDictionaryKey,
                MirriamThesaurusKey   = globalConfig.MirriamThesaurusKey,

                QualityChange      = new string[0],
                QualityChangeValue = new int[0],

                ValidZones     = TemplateCache.GetAll <IZoneTemplate>(true),
                ValidLanguages = ConfigDataCache.GetAll <ILanguage>(),

                GossipConfigDataObject = gossipConfig,
                GossipActive           = gossipConfig.GossipActive,
                ClientId                 = gossipConfig.ClientId,
                ClientSecret             = gossipConfig.ClientSecret,
                ClientName               = gossipConfig.ClientName,
                SuspendMultiplier        = gossipConfig.SuspendMultiplier,
                SuspendMultiplierMaximum = gossipConfig.SuspendMultiplierMaximum,
                SupportedChannels        = gossipConfig.SupportedChannels,
                SupportedFeatures        = gossipConfig.SupportedFeatures
            };

            return(View(dashboardModel));
        }
Beispiel #4
0
        public static void PreloadSupportingEntities()
        {
            //Load the "config" data first
            ConfigData.LoadEverythingToCache();

            LexicalProcessor.LoadWordnet();

            IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld));

            //We dont move forward without a global config
            if (globalConfig == null)
            {
                globalConfig = new GlobalConfig();

                globalConfig.SystemSave();
            }

            if (globalConfig.BaseLanguage == null)
            {
                ILanguage baseLanguage = ConfigDataCache.GetAll <ILanguage>().FirstOrDefault();

                if (baseLanguage == null)
                {
                    LoggingUtility.Log("There are no valid languages. Generating new base language.", LogChannels.SystemErrors, true);

                    baseLanguage = new Language()
                    {
                        Name = "English",
                        GoogleLanguageCode     = "en-us",
                        AntecendentPunctuation = true,
                        PrecedentPunctuation   = false,
                        Gendered = false,
                        UIOnly   = true
                    };

                    baseLanguage.SystemSave();
                }

                globalConfig.BaseLanguage = baseLanguage;
                globalConfig.SystemSave();
            }

            //Ensure we have base words for the language every time
            globalConfig.BaseLanguage.SystemSave();

            //Hoover up all the verbs from commands that someone might have coded
            ProcessSystemVerbs(globalConfig.BaseLanguage);

            IGossipConfig   gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));
            HttpApplication instance     = HttpContext.Current.ApplicationInstance;
            Assembly        asm          = instance.GetType().BaseType.Assembly;
            Version         v            = asm.GetName().Version;

            //We dont move forward without a global config
            if (gossipConfig == null)
            {
                gossipConfig = new GossipConfig
                {
                    ClientName = "Warrens: White Sands"
                };
            }

            //Update version
            gossipConfig.Version = string.Format(CultureInfo.InvariantCulture, @"{0}.{1}.{2} (r{3})", v.Major, v.Minor, v.Build, v.Revision);
            gossipConfig.SystemSave();

            //Load structural data next
            Templates.LoadEverythingToCache();

            HotBackup hotBack = new HotBackup();

            //Our live data restore failed, reload the entire world from backing data
            if (!hotBack.RestoreLiveBackup())
            {
                hotBack.NewWorldFallback();
            }

            if (gossipConfig.GossipActive)
            {
                Func <Member[]> playerList = () => LiveCache.GetAll <IPlayer>()
                                             .Where(player => player.Descriptor != null && player.Template <IPlayerTemplate>().Account.Config.GossipSubscriber)
                                             .Select(player => new Member()
                {
                    Name           = player.AccountHandle,
                    WriteTo        = (message) => player.WriteTo(new string[] { message }),
                    BlockedMembers = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => !acq.IsFriend).Select(acq => acq.PersonHandle),
                    Friends        = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => acq.IsFriend).Select(acq => acq.PersonHandle)
                }).ToArray();

                void exceptionLogger(Exception ex) => LoggingUtility.LogError(ex);
                void activityLogger(string message) => LoggingUtility.Log(message, LogChannels.GossipServer);

                GossipClient gossipServer = new GossipClient(gossipConfig, exceptionLogger, activityLogger, playerList);

                Task.Run(() => gossipServer.Launch());

                LiveCache.Add(gossipServer, "GossipWebClient");
            }

            Func <bool> backupFunction            = hotBack.WriteLiveBackup;
            Func <bool> backingDataBackupFunction = Templates.WriteFullBackup;

            //every 30 minutes after half an hour
            Processor.StartSingeltonChainedLoop("HotBackup", 30 * 60, 30 * 60, -1, backupFunction);

            //every 2 hours after 1 hour
            Processor.StartSingeltonChainedLoop("BackingDataFullBackup", 60 * 60, 120 * 60, -1, backingDataBackupFunction);
        }