public void Open() { NetConfig config = new NetConfig(); config.Host = ServerConfig.Host; config.Port = ServerConfig.Port; config.CertificateFile = ServerConfig.CertificateFile; config.CertificatePassword = ServerConfig.CertificatePassword; if (!string.IsNullOrEmpty(config.CertificateFile)) { config.SSL = true; } config.LittleEndian = false; HttpPacket hp = new HttpPacket(this.ServerConfig.BodySerializer, this.ServerConfig, this); mServer = SocketFactory.CreateTcpServer(config, this, hp); Name = "FastHttpApi Http Server"; Admin.AdminController aic = new Admin.AdminController(); aic.HandleFactory = mActionFactory; aic.Server = this; mActionFactory.Register(ServerConfig, this, aic); if (mAssemblies != null) { foreach (System.Reflection.Assembly assembly in mAssemblies) { mResourceCenter.LoadManifestResource(assembly); } } mResourceCenter.LoadManifestResource(typeof(HttpApiServer).Assembly); mResourceCenter.Path = ServerConfig.StaticResourcePath; mResourceCenter.Debug = ServerConfig.Debug; mResourceCenter.Load(); StartTime = DateTime.Now; mServer.Open(); }
public void Open() { NetConfig config = new NetConfig(); config.Host = ServerConfig.Host; config.Port = ServerConfig.Port; config.CertificateFile = ServerConfig.CertificateFile; config.CertificatePassword = ServerConfig.CertificatePassword; config.BufferSize = ServerConfig.BufferSize; config.LogLevel = ServerConfig.LogLevel; if (!string.IsNullOrEmpty(config.CertificateFile)) { config.SSL = true; } config.LittleEndian = false; HttpPacket hp = new HttpPacket(this.ServerConfig.BodySerializer, this.ServerConfig, this); mServer = SocketFactory.CreateTcpServer(config, this, hp); Name = "FastHttpApi Http Server"; Admin.AdminController aic = new Admin.AdminController(); aic.HandleFactory = mActionFactory; aic.Server = this; mActionFactory.Register(ServerConfig, this, aic); if (mAssemblies != null) { foreach (System.Reflection.Assembly assembly in mAssemblies) { mResourceCenter.LoadManifestResource(assembly); } } mResourceCenter.LoadManifestResource(typeof(HttpApiServer).Assembly); mResourceCenter.Path = ServerConfig.StaticResourcePath; mResourceCenter.Debug = ServerConfig.Debug; mResourceCenter.Load(); StartTime = DateTime.Now; mServer.Open(); AppDomain.CurrentDomain.UnhandledException += (s, e) => { using (System.IO.StreamWriter writer = new StreamWriter("__UnhandledException.txt")) { Exception error = e.ExceptionObject as Exception; writer.WriteLine(DateTime.Now); if (error != null) { writer.WriteLine(error.Message); writer.WriteLine(error.StackTrace); if (error.InnerException != null) { writer.WriteLine(error.InnerException.Message); writer.WriteLine(error.InnerException.StackTrace); } } else { writer.WriteLine("Unhandled Exception:" + e.ExceptionObject.ToString()); } writer.Flush(); } }; if (EnableLog(LogType.Info)) { mServer.Log(LogType.Info, null, "FastHttpApi Server started!"); } }