public Agent Start(AgentStartOptions startOptions = null) { agentServer.Start(); Identity = Identity .WithHost(agentServer.BaseUri.Host) .WithPort((ushort)agentServer.BaseUri.Port); // Default to LiveInspection, and correct later if wrong. // Only inspection extensions respond to InspectorSupport.AgentStarted. ClientSessionUri = new ClientSessionUri( Identity.AgentType, startOptions?.ClientSessionKind ?? ClientSessionKind.LiveInspection, Identity.Host, Identity.Port); startOptions?.AgentStarted?.Invoke(ClientSessionUri); try { var identifyAgentRequest = GetIdentifyAgentRequest(); if (identifyAgentRequest != null) { ClientSessionUri = ClientSessionUri.WithSessionKind(ClientSessionKind.Workbook); WriteAgentIdentityAsync(identifyAgentRequest).ContinueWithOnMainThread(task => { if (task.IsFaulted) { Log.Error( TAG, $"{nameof (WriteAgentIdentityAsync)}", task.Exception); IdentificationFailure?.Invoke(this, EventArgs.Empty); } }); } } catch (Exception e) { Log.Error(TAG, e); IdentificationFailure?.Invoke(this, EventArgs.Empty); } Log.Info(TAG, $"{Identity.AgentType} '{Identity.ApplicationName}' " + $"is available for interaction: {ClientSessionUri}"); return(this); }
private static void Main(string[] args) { if (Environment.OSVersion.Version.Major >= 6) { SetProcessDPIAware(); } var handle = GetConsoleWindow(); // Hide ShowWindow(handle, SW_HIDE); Tools.KillAllButMe(); try { AgentServer.Start(); Console.WriteLine("Agent Started"); } catch (Exception ex) { File.WriteAllText("Exception-" + Path.GetRandomFileName() + ".txt", ex.Message + " \n " + ex.StackTrace); } }
static void Main(string[] args) { AppDomain.MonitoringIsEnabled = true; logger.Info("Loading settings."); config.Load("./Settings.config"); dynamic result; if (Sheriffy.Check(config.Key, out result)) { logger.Info("Subscription name : {0} ", result["subscription"]["name"]); logger.Info("Subscription key : {0} ", result["subscription"]["key"]); logger.Info("Subscription remaining : {0} days", result["subscription"]["remaining"]["days"]); logger.Info("Subscription end date : {0} ", result["subscription"]["remaining"]["date"]); } else { logger.Info("Your subscription has expired or not found please contact to your provider."); Environment.Exit(100); } logger.Info("Loading librarys."); manager.LoadLibrarys(); logger.Info("Loading plugins."); manager.Load(); logger.Info("({0}) Plugin successfully loaded.", manager.Plugins.Count); logger.Info("Services are being loaded and starting."); foreach (Server module in config.Servers) { if (module.Class == typeof(GatewayServer).FullName) { GatewayServer server = new GatewayServer(); server.Bind = module.Bind; server.ID = module.ID; server.Class = module.Class; server.Description = module.Description; server.Divisions = module.Divisions; server.Server = module.Reditected; server.Start(); services.Add(server); } else if (module.Class == typeof(AgentServer).FullName) { AgentServer server = new AgentServer(); server.Bind = module.Bind; server.ID = module.ID; server.Class = module.Class; server.Description = module.Description; server.Start(); services.Add(server); } else if (module.Class == typeof(DownloadServer).FullName) { DownloadServer server = new DownloadServer(); server.Bind = module.Bind; server.ID = module.ID; server.Class = module.Class; server.Description = module.Description; server.Start(); services.Add(server); } else if (module.Class == typeof(ApiServer).FullName) { ApiServer server = new ApiServer(); server.Bind = module.Bind; server.ID = module.ID; server.Class = module.Class; server.Description = module.Description; server.OnRequestReceived += ApiServer_OnRequestReceived; server.Start(); services.Add(server); } } logger.Info("Everything is looking fine."); SetupConsole(); }