Exemple #1
0
        /// <summary>
        /// Attempts to automatically start server monitoring on application launch, if the user has
        /// this option specified in the SST configuration file.
        /// </summary>
        public async Task AttemptAutoMonitorStart()
        {
            if (!QlWindowUtils.QuakeLiveConsoleWindowExists())
            {
                Log.Write(
                    "Attempt to auto-start server monitoring on program start failed: QL instance not found.",
                    _logClassType, _logPrefix);

                MessageBox.Show(
                    @"Could not auto-start server monitoring because a running instance of Quake Live was not found!",
                    @"Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            await BeginMonitoring();
        }
Exemple #2
0
        /// <summary>
        /// Executes the specified command asynchronously.
        /// </summary>
        /// <param name="c">The cmd args.</param>
        public async Task <bool> ExecAsync(Cmd c)
        {
            if (!c.Args[1].Equals("start") &&
                !c.Args[1].Equals("stop") && !c.Args[1].Equals("reset") &&
                !c.Args[1].Equals("status"))
            {
                DisplayArgLengthError(c);
                return(false);
            }
            var qlw = new QlWindowUtils();

            if (!qlw.QuakeLiveConsoleWindowExists())
            {
                _irc.SendIrcNotice(c.FromUser,
                                   "[ERROR] A running instance of Quake Live could not be found.");

                Log.Write(string.Format(
                              "{0} attempted to use {1} command but a running instance of Quake Live could not be found. Ignoring.",
                              c.FromUser, c.CmdName), _logClassType, _logPrefix);

                return(false);
            }
            if (c.Args[1].Equals("start"))
            {
                if (_sst.IsMonitoringServer)
                {
                    _irc.SendIrcNotice(c.FromUser,
                                       "[ERROR] Your QL server is already being monitored.");

                    Log.Write(string.Format(
                                  "{0} attempted to start server monitoring but server is already being monitored. Ignoring.",
                                  c.FromUser), _logClassType, _logPrefix);

                    return(false);
                }
                _irc.SendIrcMessage(_irc.IrcSettings.ircChannel,
                                    "\u0002[SUCCESS]\u0002 Attempting to start QL server monitoring.");
                await _sst.BeginMonitoring();

                // Give it time to complete initilization, then show status.
                await Task.Delay(11000);

                ShowMonitorStatus();
            }
            else if (c.Args[1].Equals("stop"))
            {
                if (!_sst.IsMonitoringServer)
                {
                    _irc.SendIrcNotice(c.FromUser,
                                       "[ERROR] No QL server is currently being monitored.");

                    Log.Write(string.Format(
                                  "{0} attempted to stop server monitoring but server is not currently being monitored. Ignoring.",
                                  c.FromUser), _logClassType, _logPrefix);

                    return(false);
                }

                _sst.StopMonitoring();
                _irc.SendIrcMessage(_irc.IrcSettings.ircChannel,
                                    "\u0002[SUCCESS]\u0002 Stopped monitoring your QL server.");
            }
            else if (c.Args[1].Equals("reset"))
            {
                if (_sst.IsMonitoringServer)
                {
                    Log.Write(string.Format(
                                  "{0} reset server monitoring for actively monitored server; now stopping server monitoring.",
                                  c.FromUser), _logClassType, _logPrefix);

                    _irc.SendIrcMessage(_irc.IrcSettings.ircChannel,
                                        "\u0002[SUCCESS]\u0002 Your QL server was being monitored; now stopping this monitoring.");

                    _sst.StopMonitoring();
                }
                else
                {
                    Log.Write(string.Format(
                                  "{0} reset server monitoring for non-actively monitored server; now starting server monitoring.",
                                  c.FromUser), _logClassType, _logPrefix);

                    _irc.SendIrcMessage(_irc.IrcSettings.ircChannel,
                                        "\u0002[SUCCESS]\u0002 Your QL server was not being monitored; now starting monitoring.");

                    await _sst.BeginMonitoring();
                }
            }
            else if (c.Args[1].Equals("status"))
            {
                ShowMonitorStatus();
            }

            return(true);
        }