public bool IsOnline() { try { var gap = DateTime.UtcNow - FilterCore.GetLastServerDispatchUtc(); bool isOnline = gap.TotalSeconds < _offlineTimeoutSeconds; return(isOnline); // No, not this stuff /* * var worldFilter = Decal.Adapter.CoreManager.Current.WorldFilter; * if (worldFilter == null) { log.WriteError("worldFilter null"); return false; } * var inventory = worldFilter.GetInventory(); * if (inventory == null) { log.WriteError("inventory null"); return false; } * var firstObject = inventory.First; * if (firstObject == null) { log.WriteError("firstObject null"); return false; } * return Decal.Adapter.CoreManager.Current.Actions.IsValidObject(firstObject.Id); */ } catch (Exception exc) { log.WriteError("IsOnline exception: " + exc.ToString()); return(false); } }
/// <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; } }
} // for game emulator protected override void Startup() { Debug.Init(FileLocations.PluginPersonalFolder.FullName + @"\Exceptions.txt", PluginName); SettingsFile.Init(FileLocations.GetFilterSettingsFilepath(), PluginName); LogStartup(); theFilterCore = this; defaultFirstCharacterManager = new DefaultFirstCharacterManager(loginCharacterTools); chooseCharacterManager = new LauncherChooseCharacterManager(loginCharacterTools); SteelFilterCommandExecutor = new SteelFilterCommandExecutor(); SteelFilterCommandParser = new SteelFilterCommandParser(SteelFilterCommandExecutor); Heartbeat.SetCommandParser(SteelFilterCommandParser); loginNextCharacterManager = new LoginNextCharacterManager(loginCharacterTools); thwargInventory = new ThwargInventory(); SteelFilterCommandParser.Inventory = thwargInventory; ClientDispatch += new EventHandler <NetworkMessageEventArgs>(FilterCore_ClientDispatch); ServerDispatch += new EventHandler <NetworkMessageEventArgs>(FilterCore_ServerDispatch); WindowMessage += new EventHandler <WindowMessageEventArgs>(FilterCore_WindowMessage); CommandLineText += new EventHandler <ChatParserInterceptEventArgs>(FilterCore_CommandLineText); }