private static void StartSelfHosting() { var configuration = new Configuration(Settings.Default.IntegrationControllerBaseAddress); var address = configuration.BaseAddress.Scheme + "://+:" + configuration.BaseAddress.Port + "/"; using (WebApp.Start(address, appBuilder => { var builder = new ContainerBuilder(); var container = builder.Build(); var config = new HttpConfiguration { DependencyResolver = new AutofacWebApiDependencyResolver(container) }; config.MapHttpAttributeRoutes(); appBuilder.UseAutofacMiddleware(container); appBuilder.UseAutofacWebApi(config); appBuilder.UseWebApi(config); })) { Logger.InfoWithLineNumber("Started listening on port : ( " + address + " )"); QuitEvent.WaitOne(); } }
private static void StartLoadBalancerProxy(IEnumerable <Uri> managerUriList) { Logger.DebugWithLineNumber("Start."); var configuration = new Configuration(Settings.Default.ManagerLocationUri); var address = configuration.BaseAddress.Scheme + "://+:9000/StardustDashboard"; RoundRobin.Set(managerUriList.ToList()); using (WebApp.Start <LoadBalancerStartup>(address)) { Logger.InfoWithLineNumber("Load balancer started listening on port : ( " + address + " )"); QuitEvent.WaitOne(); } }
public static void Main(string[] args) { if (args.Length < 2) { PokewatchLogger.Log("[-]Missing Arguments. Indeces of account and regions must be specified.", "PokewatchUnknown"); Environment.Exit(2); } s_config = ConfigurationManager.ReadConfiguration("Pokewatch"); if (s_config == null) { Environment.Exit(2); } try { s_account = s_config.PoGoAccounts[int.Parse(args[0])]; for (int i = 1; i < args.Length; i++) { s_regions.Add(s_config.Regions[int.Parse(args[i])]); } } catch { PokewatchLogger.Log("[-]Arguments do not align with provided configuration: " + string.Join(" ", args), "PokewatchUnknown"); Environment.Exit(2); } try { s_scanAreas = s_regions.SelectMany(r => r.Locations.Select(l => new ScanArea { Location = l, Name = r.Name, Prefix = r.Prefix, Suffix = r.Suffix, Inclusions = r.Inclusions, Exclusions = r.Exclusions })).ToList(); s_currentScan = s_scanAreas.First(); s_scanIndex = 0; } catch { PokewatchLogger.Log("[-]Invalid Region Configuration", AccountManager.GetAccountName(s_account)); Environment.Exit(2); } Console.Title = AccountManager.GetAccountName(s_account) + ": " + string.Join(", ", s_regions.Select(r => r.Name)); s_pogoSession = AccountManager.SignIn(s_account, s_currentScan.Location); if (s_pogoSession == null) { PokewatchLogger.Log("[-]Unable to sign in to PokemonGo.", AccountManager.GetAccountName(s_account)); Environment.Exit(3); } if (!PrepareTwitterClient()) { Environment.Exit(4); } PokewatchLogger.Log("[+]Sucessfully signed in to twitter.", AccountManager.GetAccountName(s_account)); if (s_pogoSession.StartupAsync().Result) { PokewatchLogger.Log("[-]POGO Couldn't start.", "PokewatchUnknown"); Environment.Exit(2); } s_pogoSession.AccessTokenUpdated += (sender, eventArgs) => { PokewatchLogger.Log("[+]Access token updated.", AccountManager.GetAccountName(s_account)); }; s_pogoSession.Map.Update += (sender, eventArgs) => { PokewatchLogger.Log("[+]Location Acknowleged. Searching...", AccountManager.GetAccountName(s_account)); if (Search()) { UpdateLocation(); } }; Console.CancelKeyPress += (sender, eArgs) => { QuitEvent.Set(); eArgs.Cancel = true; }; QuitEvent.WaitOne(); }