Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, StoredDataFileAccessor storedData, StoredDataCache storedDataCache, FileLogger logger)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc();

            var dataStorage = new HotBackup(storedData, storedDataCache, logger);

            //Our live data restore failed, reload the entire world from backing data
            if (!dataStorage.RestoreLiveBackup())
            {
                dataStorage.NewWorldFallback();
            }
        }
Ejemplo n.º 2
0
        public ActionResult BackupWorld()
        {
            var hotBack = new HotBackup();

            hotBack.WriteLiveBackup();
            BackingData.WriteFullBackup();

            return RedirectToAction("Index", new { Message = "Backup Started" });
        }
Ejemplo n.º 3
0
        public ActionResult BackupWorld(string BackupName = "")
        {
            HotBackup hotBack = new HotBackup();

            hotBack.WriteLiveBackup(BackupName);
            Templates.WriteFullBackup(BackupName);
            ConfigData.WriteFullBackup(BackupName);

            return(RedirectToAction("Index", new { Message = "Backup Started" }));
        }
Ejemplo n.º 4
0
        public ActionResult RestoreWorld()
        {
            HotBackup hotBack = new HotBackup();

            //TODO: Ensure we suspend EVERYTHING going on (fights, etc), add some sort of announcement globally and delay the entire thing on a timer

            //Write the players out first to maintain their positions
            hotBack.WritePlayers();

            //restore everything
            hotBack.RestoreLiveBackup();

            return(RedirectToAction("Index", new { Message = "Restore Started" }));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles initial connection
        /// </summary>
        protected override void OnOpen()
        {
            var authTicketValue = Context.CookieCollection[".AspNet.ApplicationCookie"].Value;

            GetUserIDFromCookie(authTicketValue);

            UserManager = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));

            var authedUser = UserManager.FindById(_userId);

            var currentCharacter = authedUser.GameAccount.Characters.FirstOrDefault(ch => ch.ID.Equals(authedUser.GameAccount.CurrentlySelectedCharacter));

            if (currentCharacter == null)
            {
                Send("<p>No character selected</p>");
                return;
            }

            //Try to see if they are already live
            _currentPlayer = LiveCache.Get <Player>(currentCharacter.ID);

            //Check the backup
            if (_currentPlayer == null)
            {
                var hotBack = new HotBackup(System.Web.Hosting.HostingEnvironment.MapPath("/HotBackup/"));
                _currentPlayer = hotBack.RestorePlayer(currentCharacter.AccountHandle, currentCharacter.ID);
            }

            //else new them up
            if (_currentPlayer == null)
            {
                _currentPlayer = new Player(currentCharacter);
            }

            _currentPlayer.Descriptor = this;

            //We need to barf out to the connected client the welcome message. The client will only indicate connection has been established.
            var welcomeMessage = new List <String>();

            welcomeMessage.Add(string.Format("Welcome to alpha phase twinMUD, {0}", currentCharacter.FullName()));
            welcomeMessage.Add("Please feel free to LOOK around.");

            _currentPlayer.WriteTo(welcomeMessage);

            //Send the look command in
            Interpret.Render("look", _currentPlayer);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            var sb = new List <string>();

            var player = (Player)Actor;

            sb.Add("You save your life.");

            var messagingObject = new MessageCluster(sb, new string[] { }, new string[] { }, new string[] { }, new string[] { });

            messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation, null);

            var hotBack = new HotBackup(HostingEnvironment.MapPath("/HotBackup/"));

            //Save the player out
            hotBack.WriteOnePlayer(player);
        }
Ejemplo n.º 7
0
        public static void PreloadSupportingEntities()
        {
            var hotBack = new HotBackup(HostingEnvironment.MapPath("/HotBackup/"));

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

            var webSockServer = new Websock.Server();

            //Rooms, paths, spawns (objs then mobs)
            webSockServer.Launch(2929);

            Func<bool> backupFunction = hotBack.WriteLiveBackup;

            Processor.StartNewLoop("HotBackup", 30 * 60, 5 * 60, 1800, backupFunction);
        }
Ejemplo n.º 8
0
        public static void PreloadSupportingEntities()
        {
            var hotBack = new HotBackup(HostingEnvironment.MapPath("/HotBackup/"));

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

            var webSockServer = new Websock.Server();

            //Rooms, paths, spawns (objs then mobs)
            webSockServer.Launch(2929);

            Func <bool> backupFunction = hotBack.WriteLiveBackup;

            Processor.StartNewLoop("HotBackup", 30 * 60, 5 * 60, 1800, backupFunction);
        }
Ejemplo n.º 9
0
        public static void PreloadSupportingEntities()
        {
            //Load the "referential" data first
            BackingData.LoadEverythingToCache();
            //BackingData.LoadEverythingToCacheFromDatabase();

            var hotBack = new HotBackup();

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

            var customSockServer = new NetMud.Websock.Server();
            customSockServer.Launch(2929);

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

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

            //every 2 hours after 1 hour
            Processor.StartSingeltonChainedLoop("BackingDataFullBackup", 60 * 60, 120 * 60, -1, backingDataBackupFunction);
        }
Ejemplo n.º 10
0
        public ActionResult RestoreWorld()
        {
            var hotBack = new HotBackup();

            //TODO: Ensure we suspend EVERYTHING going on (fights, etc), add some sort of announcement globally and delay the entire thing on a timer

            //Write the players out first to maintain their positions
            hotBack.WritePlayers();

            //restore everything
            hotBack.RestoreLiveBackup();

            return RedirectToAction("Index", new { Message = "Restore Started" });
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public ActionResult BackupWorld()
        {
            var hotBack = new HotBackup(HostingEnvironment.MapPath("/HotBackup/"));

            hotBack.WriteLiveBackup();

            return RedirectToAction("Index", new { Message = "Backup Started" });
        }