private void ReadAndProcessInboundCommands() { string status = "Creating ChannelWriter"; try { var writer = new Channels.ChannelWriter(); status = "writer.ReadCommandsFromFile"; writer.ReadCommandsFromFile(_myChannel); status = "while HasInboundCommandCount"; while (_myChannel.HasInboundCommandCount()) { status = "DequeueInbound"; var cmd = _myChannel.DequeueInbound(); status = "ExecuteGameCommandString"; ExecuteGameCommandString(cmd.CommandString); status = "time stamp handling"; if (cmd.TimeStampUtc > _myChannel.LastInboundProcessedUtc) { _myChannel.LastInboundProcessedUtc = cmd.TimeStampUtc; _myChannel.NeedsToWrite = true; } status = "finishing loop"; } } catch (Exception exc) { throw new Exception("ReadAndProcessInboundCommands: " + status, exc); } }
private void StartChannelFileWatcher() { var writer = new Channels.ChannelWriter(); if (!writer.IsWatcherEnabled(_myChannel)) { writer.StartWatcher(_myChannel); _myChannel.FileWatcher.Changed += OnChannelFileWatcherChanged; } }
void CurrentDomain_ProcessExit(object sender, EventArgs e) { lock (_locker) { if (_myChannel != null) { var writer = new Channels.ChannelWriter(); if (writer.IsWatcherEnabled(_myChannel)) { writer.StopWatcher(_myChannel); } } if (_timer != null) { _timer.Stop(); } log.WriteInfo("process exit"); } }
/// <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; } }