static void Main(string[] args) { try { ConsoleColor currentForeColor = Console.ForegroundColor; var setting = new EnvironmentSetting(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine(string.Format(CharFormat, Assembly.GetExecutingAssembly().GetName().Version, setting.ProductCode, setting.ProductServerId, setting.GamePort)); GameEnvironment.Start(setting); Console.ForegroundColor = currentForeColor; if (ScriptEngines.RunMainProgram(args)) { Console.WriteLine("{0} Server has started successfully!", DateTime.Now.ToString("HH:mm:ss")); Console.WriteLine("# Server is listening..."); } else { Console.WriteLine("{0} Server failed to start!", DateTime.Now.ToString("HH:mm:ss")); } Console.ReadKey(); ScriptEngines.StopMainProgram(); } catch (Exception ex) { Console.WriteLine("{0} Server failed to start!", DateTime.Now.ToString("HH:mm:ss")); TraceLog.WriteError("Server failed to start error:{0}", ex); Console.ReadKey(); } }
/// <summary> /// Proccess stop logic /// </summary> public virtual void OnStop() { try { TraceLog.WriteLine("{0} Server is stopping, please wait.", DateTime.Now.ToString("HH:mm:ss")); ScriptEngines.StopMainProgram(); GameEnvironment.WaitStop().Wait(); TraceLog.WriteLine("{0} Server has stoped successfully!", DateTime.Now.ToString("HH:mm:ss")); } catch (Exception ex) { TraceLog.WriteError("OnStop error:{0}", ex); } }
protected void Application_End(object sender, EventArgs e) { ScriptEngines.StopMainProgram(); }