Пример #1
0
        public ArkSaveFileWatcher(ArkServerContext serverContext)
        {
            _serverContext = serverContext;

            _watcher          = new FileSystemWatcher();
            _watcher.Changed += _watcher_Changed;
            _watcher.Created += _watcher_Changed;

            SaveFilePath = serverContext.Config.SaveFilePath;
        }
Пример #2
0
 public void AddServer(ArkServerContext context)
 {
     //context.UpdateQueued += Context_UpdateTriggered;
     context.UpdateCompleted          += Context_UpdateCompleted;
     context.GameDataUpdated          += Context_GameDataUpdated;
     context.BackupCompleted          += Context_BackupCompleted;
     context._saveFileWatcher.Changed += _saveFileWatcher_Changed;
     context._contextManager           = this;
     _serverContexts.Add(context.Config.Key, context);
 }
Пример #3
0
        private void _saveFileWatcher_Changed(ArkServerContext serverContext, ArkSaveFileChangedEventArgs e)
        {
            QueueServerUpdate(serverContext);

            var clusterContext = GetCluster(serverContext.Config.ClusterKey);

            if (clusterContext == null)
            {
                return;
            }
            QueueClusterUpdate(clusterContext);
        }
Пример #4
0
        public async Task StartCountdown(ArkServerContext serverContext, string reason, int delayInMinutes, Func <Task> react = null)
        {
            // collection of servers that should receive notifications via rcon for this countdown event
            var serverContexts = serverContext == null?_contextManager.Servers.Where(x => !x.Config.DisableChatNotifications).ToArray() : new ArkServerContext[]
            {
                serverContext
            };

            foreach (var sc in serverContexts)
            {
                await sc.Steam.SendRconCommand($"serverchat Countdown started: {reason} in {delayInMinutes} minute{(delayInMinutes > 1 ? "s" : "")}...");
            }
            if (!string.IsNullOrWhiteSpace(_config.Discord.AnnouncementChannel))
            {
                await _discordManager.SendTextMessageToChannelNameOnAllServers(_config.Discord.AnnouncementChannel, $"**Countdown{(serverContext == null ? "" : $" on server {serverContext.Config.Key}")} started: {reason} in {delayInMinutes} minute{(delayInMinutes > 1 ? "s" : "")}...**");
Пример #5
0
        public ArkServerContext GetServer(string key)
        {
            if (key == null)
            {
                return(null);
            }

            ArkServerContext context = null;

            if (_serverContexts.TryGetValue(key, out context))
            {
                return(context);
            }

            return(null);
        }
Пример #6
0
        public ArkSaveFileWatcherTimer(ArkServerContext serverContext)
        {
            _serverContext = serverContext;

            _timer = new Timer(_timer_Callback, null, TimeSpan.Zero, _delay);
        }
Пример #7
0
 public void QueueUpdateServerManual(ArkServerContext serverContext)
 {
     QueueUpdateManual(serverContext, "Server", serverContext.Config.Key);
 }
Пример #8
0
 private void Context_BackupCompleted(ArkServerContext sender, bool backupsEnabled, SavegameBackupResult result)
 {
     BackupCompleted?.Invoke(sender, backupsEnabled, result);
 }
Пример #9
0
 public void QueueServerUpdate(ArkServerContext serverContext)
 {
     QueueUpdate(serverContext, "Server", serverContext.Config.Key);
 }