private IPPather GetPather(Microsoft.Extensions.Logging.ILogger logger, DataConfig dataConfig)
        {
            var scp = new StartupConfigPathing();

            Configuration.GetSection(StartupConfigPathing.Position).Bind(scp);

            bool failed = false;

            if (scp.Type == StartupConfigPathing.Types.RemoteV3)
            {
                var worldmapAreaDb = new WorldMapAreaDB(logger, dataConfig);
                var api            = new RemotePathingAPIV3(logger, scp.hostv3, scp.portv3, worldmapAreaDb);
                if (api.PingServer().Result)
                {
                    Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                    Log.Debug($"Using {StartupConfigPathing.Types.RemoteV3}({api.GetType().Name}) {scp.hostv3}:{scp.portv3}");
                    Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                    return(api);
                }

                api.RequestDisconnect();
                failed = true;
            }

            if (scp.Type == StartupConfigPathing.Types.RemoteV1 || failed)
            {
                var api = new RemotePathingAPI(logger, scp.hostv1, scp.portv1);
                if (api.PingServer().Result)
                {
                    Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

                    if (scp.Type == StartupConfigPathing.Types.RemoteV3)
                    {
                        Log.Debug($"Unavailable {StartupConfigPathing.Types.RemoteV3} {scp.hostv3}:{scp.portv3} - Fallback to {StartupConfigPathing.Types.RemoteV1}");
                    }

                    Log.Debug($"Using {StartupConfigPathing.Types.RemoteV1}({api.GetType().Name}) {scp.hostv1}:{scp.portv1}");
                    Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                    return(api);
                }

                failed = true;
            }

            Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            if (scp.Type != StartupConfigPathing.Types.Local)
            {
                Log.Debug($"{scp.Type} not available!");
            }
            Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

            var pathingService = new PPatherService(LogWrite, dataConfig);
            var localApi       = new LocalPathingApi(logger, pathingService);

            localApi.SelfTest();
            Log.Information($"Using {StartupConfigPathing.Types.Local}({localApi.GetType().Name}) pathing API.");
            Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            return(localApi);
        }
示例#2
0
        private static IPPather GetPather(Microsoft.Extensions.Logging.ILogger logger, DataConfig dataConfig)
        {
            var api = new RemotePathingAPI(logger);

            if (api.PingServer().Result)
            {
                Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                Log.Debug("Using remote pathing API");
                Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                return(api);
            }

            Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Log.Information("Using local pathing API.");
            Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            var pathingService = new PPatherService(LogWrite, dataConfig);
            var localApi       = new LocalPathingApi(logger, pathingService);

            localApi.SelfTest();
            Log.Information("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            return(localApi);
        }
 public PPatherController(PPatherService service, Logger logger)
 {
     this.service = service;
     this.logger  = logger;
 }
示例#4
0
 public LocalPathingApi(ILogger logger, PPatherService service)
 {
     this.logger  = logger;
     this.service = service;
 }