Example #1
0
        /// <summary>
        /// Determines whether the text matches that of a message that would indicate that the
        /// client running SST has left the server, and handles it if it does.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns><c>true</c> if a disconnect message was detected, otherwise <c>false</c></returns>
        private bool QuakeLiveDisconnectedDetected(string text)
        {
            if (!_sst.Parser.CvarSetQlDisconnected.IsMatch(text) &&
                !_sst.Parser.MsgErrorDisconnected.IsMatch(text))
            {
                return(false);
            }

            Log.Write("Detected that we've disconnected from Quake Live server. Stopping server monitoring.",
                      _logClassType, _logPrefix);

            // Stop monitoring, stop reading console, set server as disconnected.
            _sst.StopMonitoring();

            return(true);
        }
Example #2
0
        /// <summary>
        /// Handles the scan to check to see if SST is still connected to a Quake Live server.
        /// </summary>
        public void HandleDisconnectionScan()
        {
            if (_sst.IsDisconnectionScanPending)
            {
                return;
            }
            if (!_sst.IsInitComplete)
            {
                return;
            }
            _sst.IsDisconnectionScanPending = true;
            _disconnectScanTimer            = new Timer(15000)
            {
                AutoReset = false, Enabled = true
            };
            _disconnectScanTimer.Elapsed += async(sender, args) =>
            {
                await _sst.CheckQlServerConnectionExists();

                // If connection no longer exists then we need to stop monitoring the non-existent
                // server and shutdown all console reading.
                if (!_sst.ServerInfo.IsQlConnectedToServer)
                {
                    Log.Write("Determined that QL server connection no longer exists; Will stop all" +
                              " server monitoring.", _logClassType, _logPrefix);

                    // Stop monitoring, stop reading console, set server as disconnected.
                    _sst.StopMonitoring();
                }

                // Clear the current players so preexisting players from last map (if any) don't remain (TEST)
                _sst.ServerInfo.CurrentPlayers.Clear();
                // Verify teams (TEST)
                await _sst.QlCommands.QlCmdDelayedConfigStrings(4, 3);

                _sst.IsDisconnectionScanPending = false;
                _disconnectScanTimer.Enabled    = false;
                _disconnectScanTimer            = null;
            };

            Log.Write("Will check if server connection still exists in 15 seconds.",
                      _logClassType, _logPrefix);
        }