Example #1
0
        static void Main(string[] args)
        {
            //Your Elite Dangerous game path
            string path = "C:\\Users\\your_user_name\\Saved Games\\Frontier Developments\\Elite Dangerous";

            var statusWatcher = new StatusWatcher(path);

            statusWatcher.StatusUpdated += StatusWatcher_StatusUpdated;

            statusWatcher.StartWatching();

            var watcher = new JournalWatcher(path);

            watcher.GetEvent <FileheaderEvent>()?.AddHandler((s, e) => Console.WriteLine("Heading received: gameversion {0}, build {1}.", e.GameVersion, e.Build));
            watcher.GetEvent <ScanEvent>()?.AddHandler((s, e) => Console.WriteLine("Scanned a body {0}, it is {1}landable.", e.BodyName, (e.Landable ?? false) ? "" : "not "));
            watcher.GetEvent <DockedEvent>()?.AddHandler((s, e) => Console.WriteLine("Docked at {0}", e.StationName));

            watcher.GetEvent <FSDTargetEvent>()?.AddHandler((s, e) =>
            {
                Console.WriteLine("FSDTargetEvent");
                TPLink.Patterns.FSDTarget();
                if (IsDocked)
                {
                    TPLink.Patterns.ResetDocked();
                }
            });

            watcher.GetEvent <StartJumpEvent>()?.AddHandler((s, e) =>
            {
                Console.WriteLine("StartJumpEvent [{0}]", e.JumpType);
                TPLink.Patterns.FSDEntry();
            });
            watcher.GetEvent <FSDJumpEvent>()?.AddHandler((s, e) =>
            {
                Console.WriteLine("FSDJumpEvent [{0}]", e.StarSystem);
                TPLink.Patterns.FSDReset();
            });
            //watcher.GetEvent<SupercruiseEntryEvent>()?.AddHandler((s, e) => Console.WriteLine("SupercruiseEntryEvent"));
            watcher.GetEvent <SupercruiseExitEvent>()?.AddHandler((s, e) =>
            {
                Console.WriteLine("SupercruiseExitEvent [{0}, {1}]", e.StarSystem, e.BodyType);
                TPLink.Patterns.FSDReset();
            });

            watcher.GetEvent <DiedEvent>()?.AddHandler((s, e) =>
            {
                Console.WriteLine("Killed by {0}",
                                  e.Killers
                                  .Select(k => string.Format("{0} ({2}, flying a {1})", k.Name, k.Ship, k.Rank))
                                  .Aggregate((x, y) => string.Format("{0}, {1}", x, y)));
            });

            watcher.GetEvent <RankEvent>()?.AddHandler((s, e) => Console.WriteLine("Combat rank is {0}, Exploration rank is {1}", e.Combat.ToString(), e.Explore.ToString()));

            watcher.StartWatching().Wait();

            Console.ReadLine();

            watcher.StopWatching();
        }
Example #2
0
        static void Main(string[] args)
        {
            // Uncomment this line of code to allow for debugging
            //while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); }

            Logger.Instance.LogMessage(TracingLevel.INFO, "Init Elite Api");

            try
            {
                GetKeyBindings(null);


                var journalPath = StandardDirectory.FullName;

                Logger.Instance.LogMessage(TracingLevel.INFO, "journal path " + journalPath);

                if (!Directory.Exists(journalPath))
                {
                    Logger.Instance.LogMessage(TracingLevel.FATAL, $"Directory doesn't exist {journalPath}");
                }

                var defaultFilter = @"Journal.*.log";
//#if DEBUG
                //defaultFilter = @"JournalAlpha.*.log";
//#endif

                StatusWatcher = new StatusWatcher(journalPath);

                StatusWatcher.StatusUpdated += EliteData.HandleStatusEvents;

                StatusWatcher.StartWatching();

                JournalWatcher = new JournalWatcher(journalPath, defaultFilter);

                JournalWatcher.AllEventHandler += EliteData.HandleEliteEvents;

                JournalWatcher.StartWatching().Wait();

                CargoWatcher = new CargoWatcher(journalPath);

                CargoWatcher.CargoUpdated += EliteData.HandleCargoEvents;

                CargoWatcher.StartWatching();
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.FATAL, $"Elite Api: {ex}");
            }


            //EliteAPI.Events.AllEvent += (sender, e) => Console.Beep();

            Profile.ReadProfiles();


            SDWrapper.Run(args);
        }
Example #3
0
        public void Start()
        {
            Log.Instance.Info("Server Core starting");
            ServerCoreState = State.Starting;

            // Start Game Data Worker Thread
            Log.Instance.Info("Starting Game data worker");
            GameDataWorkerCTS = new CancellationTokenSource();
            GameDataTask      = new Task(new Action(GameDataWorkerThread), GameDataWorkerCTS.Token);
            GameDataTask.ContinueWith(GameDataWorkerThreadEnded);
            GameDataTask.Start();

            // Start tracking game events
            StatusWatcher.StartWatching();
            JournalWatcher.StartWatching();

            // Start Matric Flashing Lights thread
            matricapi.StartMatricFlashWorker();

            // Start Panel Server Thread
            if (Properties.Settings.Default.EnablePanelServer == true)
            {
                Log.Instance.Info("Starting Panel Server");
                try
                {
                    var panelServerUrl     = "http://*:" + Properties.Settings.Default.PanelServerPort;
                    var panelServerBuilder = WebApplication.CreateBuilder(Program.GetArgs());

                    panelServerBuilder.Services.AddMvcCore().AddMvcOptions(options => options.EnableEndpointRouting = false);
                    panelServerBuilder.Services.AddCors(cors => cors.AddPolicy("CorsPolicy", builder => {
                        builder
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials()
                        .WithOrigins(panelServerUrl);
                    }));
                    panelServerBuilder.Services.AddControllers().AddNewtonsoftJson();
                    panelServerBuilder.Services.AddSignalR();
                    var panelServer = panelServerBuilder.Build();

                    if (panelServer.Environment.IsDevelopment())
                    {
                        panelServer.UseDeveloperExceptionPage();
                    }

                    Log.Instance.Info("Listening on {panelserverurl}", panelServerUrl);
                    panelServer.Urls.Add(panelServerUrl);
                    panelServer.UseStaticFiles();
                    panelServer.UseRouting();
                    panelServer.UseMvc();
                    panelServer.UseCors("CorsPolicy");

                    panelServer.MapHub <GameDataUpdateHub>("/gamedataupdatehub");
                    var hubContext = panelServer.Services.GetService(typeof(IHubContext <GameDataUpdateHub>)) as IHubContext <GameDataUpdateHub>;
                    GameDataUpdateController = new GameDataUpdateController(hubContext);


                    PanelServerCTS  = new CancellationTokenSource();
                    PanelServerTask = panelServer.RunAsync(PanelServerCTS.Token);
                    PanelServerTask.ContinueWith(PanelServerThreadEnded);
                    PanelServerStarted = true;
                }
                catch (Exception ex)
                {
                    Log.Instance.Error("Exception: {exception}", ex.ToString());
                    PanelServerStarted = false;
                }
            }

            ServerCoreState = State.Started;
            ServerConsole.UpdateServerStatus(ServerCoreState);
            Log.Instance.Info("Server Core started");
        }
Example #4
0
        static void Main(string[] args)
        {
            // Uncomment this line of code to allow for debugging
            //while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); }

            Logger.Instance.LogMessage(TracingLevel.INFO, "Init Elite Api");

            try
            {
                var journalPath = StandardDirectory.FullName;

                Logger.Instance.LogMessage(TracingLevel.INFO, "journal path " + journalPath);

                if (!Directory.Exists(journalPath))
                {
                    Logger.Instance.LogMessage(TracingLevel.FATAL, $"Directory doesn't exist {journalPath}");
                }

                statusWatcher = new StatusWatcher(journalPath);

                statusWatcher.StatusUpdated += EliteData.HandleStatusEvents;

                statusWatcher.StartWatching();

                watcher = new JournalWatcher(journalPath);

                watcher.AllEventHandler += EliteData.HandleEliteEvents;

                watcher.StartWatching().Wait();

                var bindingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Frontier Developments\Elite Dangerous\Options\Bindings");

                Logger.Instance.LogMessage(TracingLevel.INFO, "bindings path " + bindingsPath);

                if (!Directory.Exists(bindingsPath))
                {
                    Logger.Instance.LogMessage(TracingLevel.FATAL, $"Directory doesn't exist {bindingsPath}");
                }

                var bindsName = File.ReadAllText(Path.Combine(bindingsPath, "StartPreset.start"));

                var fileName = Path.Combine(bindingsPath, bindsName + ".3.0.binds");

                if (!File.Exists(fileName))
                {
                    //Logger.Instance.LogMessage(TracingLevel.ERROR, "file not found " + fileName);

                    fileName = fileName.Replace(".3.0.binds", ".binds");

                    if (!File.Exists(fileName))
                    {
                        bindingsPath = SteamPath.FindSteamEliteDirectory();

                        if (!string.IsNullOrEmpty(bindingsPath))
                        {
                            fileName = Path.Combine(bindingsPath, bindsName + ".3.0.binds");

                            if (!File.Exists(fileName))
                            {
                                //Logger.Instance.LogMessage(TracingLevel.ERROR, "file not found " + fileName);

                                fileName = fileName.Replace(".3.0.binds", ".binds");
                            }
                        }
                    }
                }

                var serializer = new XmlSerializer(typeof(UserBindings));

                Logger.Instance.LogMessage(TracingLevel.INFO, "using " + fileName);

                var reader = new StreamReader(fileName);
                Bindings = (UserBindings)serializer.Deserialize(reader);
                reader.Close();
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.FATAL, $"Elite Api: {ex}");
            }


            //EliteAPI.Events.AllEvent += (sender, e) => Console.Beep();


            SDWrapper.Run(args);
        }