Ejemplo n.º 1
0
        public static async void PerformBackups(CancellationToken token)
        {
            while (ServerContext.ServerRunning)
            {
                if (ServerContext.PlayerCount > 0)
                {
                    LunaLog.Debug("Performing backups...");
                    VesselStoreSystem.BackupVessels();
                    WarpSystem.SaveLatestSubspaceToFile();
                    ScenarioStoreSystem.BackupScenarios();
                }
                else
                {
                    LunaLog.Debug("Skipping backups: No players online.");
                }

                try
                {
                    await Task.Delay(IntervalSettings.SettingsStore.BackupIntervalMs, token);
                }
                catch (TaskCanceledException)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 public static void RunBackup()
 {
     lock (LockObj)
     {
         LunaLog.Debug("Performing backups...");
         VesselStoreSystem.BackupVessels();
         WarpSystem.BackupSubspaces();
         ScenarioStoreSystem.BackupScenarios();
     }
 }
Ejemplo n.º 3
0
        public static void SendScenarioModules(ClientStructure client)
        {
            var scenarioDataArray = ScenarioStoreSystem.CurrentScenariosInXmlFormat.Keys.Select(s =>
            {
                var scenarioConfigNode = ScenarioStoreSystem.GetScenarioInConfigNodeFormat(s);
                var serializedData     = Encoding.UTF8.GetBytes(scenarioConfigNode);
                return(new ScenarioInfo
                {
                    Data = serializedData,
                    NumBytes = serializedData.Length,
                    Module = Path.GetFileNameWithoutExtension(s)
                });
            }).ToArray();

            var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <ScenarioDataMsgData>();

            msgData.ScenariosData = scenarioDataArray;
            msgData.ScenarioCount = scenarioDataArray.Length;

            MessageQueuer.SendToClient <ScenarioSrvMsg>(client, msgData);
        }
Ejemplo n.º 4
0
        public static async void PerformBackups(CancellationToken token)
        {
            while (ServerContext.ServerRunning)
            {
                LunaLog.Debug("Performing backups...");
                VesselStoreSystem.BackupVessels();
                WarpSystem.SaveSubspacesToFile();
                ScenarioStoreSystem.BackupScenarios();
                try
                {
                    await Task.Delay(IntervalSettings.SettingsStore.BackupIntervalMs, token);
                }
                catch (TaskCanceledException)
                {
                    break;
                }
            }

            //Do a last backup before quitting
            VesselStoreSystem.BackupVessels();
            WarpSystem.SaveSubspacesToFile();
            ScenarioStoreSystem.BackupScenarios();
        }