public void Run(bool startDiscovery = false) { var log = string.Empty; try { if (startDiscovery) { InstanceRegistry.SubscribeForNotifications(); discoveryIsRunning = true; } if (File.Exists(ServerConstants.SERVER_STARTUP_FILE)) { //netsh http add urlacl url=http://+:25600/ user=gavin.vandermerwe var startUpConfigString = File.ReadAllText(ServerConstants.SERVER_STARTUP_FILE); var connectionInfo = JsonConvert.DeserializeObject<ServerConnectionInfo>(startUpConfigString); server = new AgentServer(new ServerConnectionInfo(connectionInfo.Host, connectionInfo.Port)); server.Listen(); log += string.Format("\r\n{0} - Launched listener. {1}:{2}.", DateTimeProvider.Now().ToString("dd MMM yyyy HH:mm:ss"), connectionInfo.Host, connectionInfo.Port); } } catch (Exception err) { log += string.Format("\r\n{0} - Error. {1}", DateTimeProvider.Now().ToString("dd MMM yyyy HH:mm:ss"), err); File.WriteAllText(PathProvider.Translate("_error.log"), err.ToString()); } log += string.Format("\r\n{0} - Main thread complete.", DateTimeProvider.Now().ToString("dd MMM yyyy HH:mm:ss")); File.WriteAllText(PathProvider.Translate("_ok.log"), log); }
protected Agent(bool unitTestContext) { MainThread.Initialize(); agentServer = new AgentServer(this); evaluationContextManager = new Lazy <EvaluationContextManager> (() => { MainThread.Ensure(); var host = CreateEvaluationContextManager(); host.Events.Subscribe(new Observer <ICodeCellEvent> (evnt => { switch (evnt) { case EvaluationInFlight _: break; default: MessageChannel.Push(evnt); break; } })); return(host); }); if (!unitTestContext) { RepresentationManager.AddProvider(new ReflectionRepresentationProvider()); } }
protected Agent(bool unitTestContext) { agentServer = new AgentServer(this); if (!unitTestContext) { RepresentationManager.AddProvider(new ReflectionRepresentationProvider()); } }
/// <summary> /// Ask agent to speak /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSpeak_Click(object sender, System.EventArgs e) { AgentServer Srv = new AgentServer(); if (Srv == null) { MessageBox.Show("ERROR: Agent Server couldn't be started!"); } IAgentEx SrvEx; // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object SrvEx = (IAgentEx)Srv; // First try to load the default character int dwCharID = 0, dwReqID = 0; try { // null is used where VT_EMPTY variant is expected by the COM object String strAgentCharacterFile = null; if (!strFileName.Equals(string.Empty)) { //Get the acs path strAgentCharacterFile = strPath + strFileName; } else { MessageBox.Show("Select Style"); return; } if (TxtSpeakInput.Text.Equals(string.Empty)) { TxtSpeakInput.Text = "Please enter text in textbox"; } SrvEx.Load(strAgentCharacterFile, out dwCharID, out dwReqID); } catch (Exception) { MessageBox.Show("Failed to load Agent character! Exception details:"); } SrvEx.GetCharacterEx(dwCharID, out CharacterEx); //CharacterEx.SetLanguageID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); // Show the character. The first parameter tells Microsoft // Agent to show the character by playing an animation. // Make the character speak // Second parameter will be transferred to the COM object as NULL CharacterEx.Speak(TxtSpeakInput.Text, null, out dwReqID); }
/// <summary> /// Show Agent /// </summary> private void ShowAgent() { AgentServer Srv = new AgentServer(); if (Srv == null) { MessageBox.Show("ERROR: Agent Server couldn't be started!"); } IAgentEx SrvEx; // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object SrvEx = (IAgentEx)Srv; // First try to load the default character int dwCharID = 0, dwReqID = 0; try { // null is used where VT_EMPTY variant is expected by the COM object String strAgentCharacterFile = null; if (!strFileName.Equals(string.Empty)) { //Get the acs path strAgentCharacterFile = strPath + strFileName; } else { MessageBox.Show("Select Style"); return; } if (TxtSpeakInput.Text.Equals(string.Empty)) { TxtSpeakInput.Text = "Please enter text in textbox"; } //load the acs file SrvEx.Load(strAgentCharacterFile, out dwCharID, out dwReqID); } catch (Exception) { MessageBox.Show("Failed to load Agent character! Exception details:"); } SrvEx.GetCharacterEx(dwCharID, out CharacterEx); //show the agent CharacterEx.Show(0, out dwReqID); }
public void TestFixtureSetUp() { if (!RUN_AGAINST_WINDOWS_SERVICE) { server = AgentServerBuilder.New() .WithIp("<this-ip>") .WithPort(TestConstants.SERVER_PORT) .WithDiscovery() .Create() .Listen(); } client = AgentClientBuilder.New() .WithIp("<this-ip>") .WithPort(TestConstants.SERVER_PORT) .Create() .Start(); }
void Awake() { if (instance != null && instance != this) { DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); string[] args = System.Environment.GetCommandLineArgs(); for (int i = 0; i < args.Length; i++) { if ("port".Equals(args[i])) { m_Port = int.Parse(args[i + 1]); } } }
public void Initialize() { if (m_SrvEx != null) { return; //Already initialized } Thread.CurrentThread.SetApartmentState(ApartmentState.STA); try { AgentServer AgSrv = new AgentServer(); // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object m_SrvEx = (IAgentEx)AgSrv; m_Sink = new AgentNotifySink(); m_Sink.Register(m_SrvEx); } catch (Exception e) { AgentServerStartupException ex = new AgentServerStartupException("Agent Server could not be started", e); Console.WriteLine(ex); throw ex; } }
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(); }
public void Initialize() { if (m_SrvEx != null) { return; //Already initialized } Thread.CurrentThread.SetApartmentState(ApartmentState.STA); try { AgentServer AgSrv = new AgentServer(); // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object m_SrvEx = (IAgentEx)AgSrv; m_Sink = new AgentNotifySink(); m_Sink.Register(m_SrvEx); } catch (Exception e) { AgentServerStartupException ex = new AgentServerStartupException("Agent Server could not be started", e); Console.WriteLine(ex); throw ex; } }