}//InitializeTabs() // // // ********************************************* // **** StartServices() **** // ********************************************* private void StartServices() { // // Set Application services. // UV.Lib.Application.AppServices appServices = UV.Lib.Application.AppServices.GetInstance(); appServices.Info.RequestShutdownAddHandler(new EventHandler(Service_RequestShutdown)); appServices.ServiceStopped += new EventHandler(Service_ServiceStopped); appServices.ServiceAdded += new EventHandler(Service_ServiceAdded); // Listen to Win32 Sessions // TODO: Can these be handled within our AppServices class, and pass along these to Service_RequestShutdown Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding; Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; // Load services from config file. appServices.TryLoadServicesFromFile(m_ConfigFileName); appServices.Start(); // Tells sevices to start threads, all initialization. List <IService> serviceList = appServices.GetServices(typeof(FrontEndServer)); if (serviceList.Count > 0) { m_FrontEndServer = (FrontEndServer)serviceList[0]; // use first front end as my log. } appServices.Connect(); // Update Violet form this.Text = string.Format("{0}", appServices.User); }// StartServices
}//UpdateThisControl(); // // // // ***************************************************** // **** Create ServiceListEntry() **** // ***************************************************** /// <summary> /// Called each time new service is added to application. Here, it is examined /// and added to our list. /// </summary> /// <param name="serviceName"></param> /// <param name="entry"></param> /// <returns></returns> private bool TryCreateServiceListEntry(string serviceName, out ServiceListEntry entry) { IService iService; if (m_AppServices.TryGetService(serviceName, out iService)) { // Discover a frontend server to which we can send requests. if (m_FrontEndServer == null && iService is FrontEndServer) { m_FrontEndServer = (FrontEndServer)iService; } // Create a entry element for this service. entry = new ServiceListEntry(); entry.ServiceName = serviceName; entry.ServiceClassName = iService.GetType().Name; entry.Service = iService; if (iService is ForeignService) { ForeignService foreignService = (ForeignService)iService; entry.IsForeign = true; string[] s = foreignService.ClassName.Split('.'); entry.ServiceClassName = s[s.Length - 1]; } return(true); } else { entry = null; return(false); } }// TryCreateServiceListEntry()
static void Main(string[] args) { var simul = new SimulationServer(typeof(ExampleGame)); var frontend = new FrontEndServer("FrontEnd", "index.html"); var server = new RouteServer <SimulationServer>(simul); server.AppendRoutes(frontend); var waiter = new ManualResetEvent(false); Console.CancelKeyPress += (o, e) => { e.Cancel = true; waiter.Set(); }; server.StartAsync(); Console.WriteLine("tart started.. press ctrl+c to stop"); waiter.WaitOne(); server.Stop(); }