void Start() { AppDomain.CurrentDomain.UnhandledException += this.OnUnhandledException; Application.runInBackground = true; Application.targetFrameRate = 60; DontDestroyOnLoad(this.gameObject); Env.isEditor = Application.isEditor; Env.isRunning = true; Env.platform = ( int )Application.platform; Env.useNetwork = this.useNetwork; Env.StartTime(); LoggerProxy.Init(Application.dataPath.Replace("\\", "/") + "/../Log/", this.logServerIp, this.logServerPort); LoggerProxy.logLevel = this.logLevel; Defs.Init(Resources.Load <TextAsset>("Defs/b_defs").text); UIManager.Init(); if (Env.useNetwork) { NetworkManager.SetupKCP(); Windows.CONNECTING_WIN.Open(NetworkConfig.CONNECTION_TIMEOUT / 1000f); NetModule.Initialize(this.useKCP ? NetworkManager.PType.Kcp : NetworkManager.PType.Tcp); NetModule.instance.OnSocketEvent += this.OnSocketEvent; NetModule.instance.Connect(this.ip, this.port); } else { Standalone.Init(this.cid, ( byte )this.image, this.map); Standalone.Load(); } }
public UnitTest(ITestOutputHelper o) { output = o; AssemblyName[] assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies(); foreach (AssemblyName assembly in assemblies) { Assembly.Load(assembly); } LoggerProxy.Init(Resources.log4net_config); }
private void Start() { AppDomain.CurrentDomain.UnhandledException += this.OnUnhandledException; Application.runInBackground = true; Application.targetFrameRate = 60; DontDestroyOnLoad(this.gameObject); Env.isEditor = Application.isEditor; Env.isRunning = true; Env.platform = ( int )Application.platform; Env.StartTime(); LoggerProxy.Init(Application.dataPath.Replace("\\", "/") + "/../Log/", this.logServerIp, this.logServerPort); LoggerProxy.logLevel = this.logLevel; AssetsManager.Init(Application.streamingAssetsPath); AssetsManager.LoadManifest(this.OnManifestLoadComplete, this.OnManifestLoadError, false, Application.productName); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddApplicationInsights(app.ApplicationServices); LoggerProxy.Init(loggerFactory); UsersDal.Initialize(Configuration["Mongodb"]); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(); }
static int Start(string[] args) { AssemblyName[] assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies(); foreach (AssemblyName assembly in assemblies) { Assembly.Load(assembly); } LoggerProxy.Init(Resources.log4net_config); CommandArgs commandArg = CommandLine.Parse(args); Dictionary <string, string> argPairs = commandArg.argPairs; int maxClient; if (!argPairs.ContainsKey("c")) { maxClient = 10; } else { if (!int.TryParse(argPairs["c"], out maxClient)) { Logger.Log("最大连接数解析错误"); return(1); } } if (!argPairs.ContainsKey("p")) { Logger.Log("没有指定端口"); return(1); } if (!int.TryParse(argPairs["p"], out int _port)) { Logger.Log("端口解析错误"); return(1); } int useUDP; if (!argPairs.ContainsKey("t")) { useUDP = 0; } else { if (!int.TryParse(argPairs["t"], out useUDP)) { Logger.Log("协议类型解析错误"); return(1); } } if (!argPairs.ContainsKey("d")) { Logger.Log("无效的配置文件路径"); return(1); } string defFile = argPairs["d"]; string json; try { json = File.ReadAllText(defFile); } catch (Exception e) { Logger.Log(e); return(1); } Defs.Init(json); _handlerCenter = new HandlerCenter(); NetworkManager.PType protocolType = useUDP > 0 ? NetworkManager.PType.Kcp : NetworkManager.PType.Tcp; if (protocolType == NetworkManager.PType.Kcp) { NetworkManager.SetupKCP(); } NetworkManager.AddPacketTypes(); NetworkManager.CreateServer(NETWORK_NAME, protocolType, maxClient); NetworkManager.AddServerEventHandler(NETWORK_NAME, ProcessServerEvent); NetworkManager.StartServer(NETWORK_NAME, _port); Logger.Log($"Server started, listening port: {_port}"); Thread inputThread = new Thread(InputWorker); inputThread.IsBackground = true; inputThread.Start(); System.Diagnostics.Stopwatch sp = new System.Diagnostics.Stopwatch(); sp.Start(); long lastElapsed = 0; while (!_disposed) { long elapsed = sp.ElapsedMilliseconds; long dt = elapsed - lastElapsed; NetworkManager.Update(dt); lastElapsed = elapsed; ProcessInput(); Thread.Sleep(10); } sp.Stop(); inputThread.Join(); LoggerProxy.Dispose(); return(0); }