Beispiel #1
0
        /// <summary>
        /// This may be called on timer thread *OR* on external caller's thread
        /// </summary>
        private void SendAndReceiveCommands()
        {
            bool success = true;

            try
            {
                _status.TeamList = _cmdParser.GetTeamList();
                _status.IsOnline = IsOnline();
                _status.LastServerDispatchSecondsAgo = (int)(DateTime.UtcNow - FilterCore.GetLastServerDispatchUtc()).TotalSeconds;
                LaunchControl.RecordHeartbeatStatus(_gameToLauncherFilepath, _status);
            }
            catch (Exception exc)
            {
                success = false;
                log.WriteError("Exception writing heartbeat status: " + exc.ToString());
            }
            try
            {
                if (_myChannel.NeedsToWrite)
                {
                    var writer = new Channels.ChannelWriter();
                    writer.WriteCommandsToFile(_myChannel);
                }
            }
            catch (Exception exc)
            {
                success = false;
                log.WriteError("Exception writing command file status: " + exc.ToString());
            }
            try
            {
                ReadAndProcessInboundCommands();
            }
            catch (Exception exc)
            {
                success = false;
                log.WriteError("Exception reading command file status: " + exc + " - " + exc.StackTrace);
            }
            if (success)
            {
                LastSendAndReceive = DateTime.UtcNow;
            }
        }