コード例 #1
0
ファイル: ArkSaveFileWatcher.cs プロジェクト: qwe900/ArkBot
        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);
 }