public static void tailNetLog(MessageBus messageBus) { //string path, string logFile, long seekPos, Int32 elitePid Int32 lastElitePid = -1; string lastSystem = null; int lastDockedStatus = -1; //Unknown State long seekPos = 0; string logFile = null; while (true) { Thread.Sleep(5000); Int32 checkPid = Elite.getPID(); if (logFile == null || (checkPid != lastElitePid && checkPid >= 0)) { lastElitePid = checkPid; logFile = getLatestNetlog(); seekPos = 0; Debug.Write("Game state change detected. Watching new netlog: " + logFile); } if (logFile != null) { Tuple <string, double, double, double, int, long> tResponse = getDataFromNetlog(logFile, seekPos); if (tResponse.Item1 != null) { messageBus.currentSystem = tResponse.Item1; messageBus.currentX = tResponse.Item2; messageBus.currentY = tResponse.Item3; messageBus.currentZ = tResponse.Item4; } if (tResponse.Item5 != -1) { messageBus.isDocked = tResponse.Item5; } long newseekPos = tResponse.Item6; if (newseekPos != seekPos) { seekPos = newseekPos; } if (messageBus.currentSystem != null && messageBus.currentSystem != lastSystem) { Debug.Write("Current System: " + messageBus.currentSystem + "(" + messageBus.currentX.ToString() + "," + messageBus.currentY.ToString() + "," + messageBus.currentZ.ToString() + ")"); lastSystem = messageBus.currentSystem; } if (lastDockedStatus != messageBus.isDocked) { Debug.Write("Docked Status changed to: " + messageBus.isDocked.ToString()); if (messageBus.isDocked == 1) { Thread.Sleep(7000); if (messageBus.loggedinState == "ok") { Companion.getProfile(messageBus); Announcements.eddnAnnouncement(messageBus); Eddn.updateEddn(messageBus); } } lastDockedStatus = messageBus.isDocked; } } } }