public void Start() { IPEndPoint ep = new IPEndPoint(IPAddress.Parse(RemoteEndPoint.Host), RemoteEndPoint.Port); Console.WriteLine($"Binding to endpoint {ep}", Color.White); var client = new UdpClient(); client.Connect(ep); commandStart: Console.WriteLine(Helptext, Color.LightGray); while (true) { Console.WriteLine("Enter command:", Color.Gray); var cmdLine = Console.ReadLine(); //var cmdLine = "echo:a"; var command = CmdParser.ParseCommandLine(cmdLine); if (command == null) { Console.WriteLine($"Unknown Command {cmdLine}", Color.Red); goto commandStart; } var payloadBytes = CreatePayloadBytes(command); client.Send(payloadBytes, payloadBytes.Length); Console.WriteLine($"Waiting for response ..."); // receive var responsePayloadBytes = client.Receive(ref ep); Console.WriteLine($"Received data from {ep}"); var response = ReadResponse(responsePayloadBytes); Console.WriteLine(response, Color.AntiqueWhite); } }
public static string ProcessDebugCommand(DebugCommand message) { var result = string.Empty; switch (message.Command) { case DebugCommands.ShowConfig: var config = message.Args[0] as string; switch (config) { case "camera": result = SingletonManager.Get <CameraConfigManager>().XMLContent; break; } break; case DebugCommands.EnableRecordProfiler: { var isClient = true; var enabled = false; if (message.Args.Length == 1) { enabled = int.Parse(message.Args[0]) != 0; } else if (message.Args.Length == 2) { isClient = message.Args[0].ToLower().Equals("c"); enabled = int.Parse(message.Args[1]) != 0; } if (isClient && !SharedConfig.IsServer || !isClient && SharedConfig.IsServer) { if (enabled) { SingletonManager.Get <MyProfilerManager>().EnableProfiler(); } else { SingletonManager.Get <MyProfilerManager>().DisableProfiler(); } } break; } case DebugCommands.EnableProfiler: { var cmdargs = CmdParser.ParseCommandLine(message.Args, "-"); var isClient = false; var isServer = false; var value = 0; isClient = TryGetArgs <int>(cmdargs, "c", out value); if (!isClient) { isServer = TryGetArgs <int>(cmdargs, "s", out value); } var enabled = value != 0; var isProfileGpu = TryGetArgs <int>(cmdargs, "g", out value); var profileGpu = value != 0; //profilegpu is only valid on client profileGpu = !SharedConfig.IsServer && profileGpu; if (isClient && !SharedConfig.IsServer || isServer && SharedConfig.IsServer) { if (enabled) { UnityProfiler.EnableProfiler(profileGpu); result = String.Format("ok, start {0} profiler profile gpu {1}", SharedConfig.IsServer ? "server" : "client", profileGpu ? "enabled" : "disabled"); } else { UnityProfiler.DisableProfiler(); result = "ok, stop profiler"; } } else if (isProfileGpu) { UnityProfiler.EnableProfileGpu(profileGpu); result = String.Format("ok, profile gpu {0}", (profileGpu ? "enabled" : "disabled")); } else if (!isServer) { result = "Invalid Argument."; } break; } } return(result); }
public static string ProcessDebugCommand(DebugCommand message, Contexts context) { var result = string.Empty; switch (message.Command) { case DebugCommands.ListTriggerObj: result = ListTriggerObj(context.mapObject, message.Args); break; case DebugCommands.ListDoorEntity: break; case DebugCommands.ShowConfig: var config = message.Args[0] as string; switch (config) { case "camera": result = SingletonManager.Get <CameraConfigManager>().XMLContent; break; } break; case DebugCommands.EnableRecordProfiler: { var isClient = true; var enabled = false; if (message.Args.Length == 1) { enabled = int.Parse(message.Args[0]) != 0; } else if (message.Args.Length == 2) { isClient = message.Args[0].ToLower().Equals("c"); enabled = int.Parse(message.Args[1]) != 0; } if (isClient && !SharedConfig.IsServer || !isClient && SharedConfig.IsServer) { if (enabled) { SingletonManager.Get <MyProfilerManager>().EnableProfiler(); } else { SingletonManager.Get <MyProfilerManager>().DisableProfiler(); } } break; } case DebugCommands.EnableProfiler: { var cmdargs = CmdParser.ParseCommandLine(message.Args, "-"); var isClient = false; var isServer = false; var value = 0; isClient = TryGetArgs <int>(cmdargs, "c", out value); if (!isClient) { isServer = TryGetArgs <int>(cmdargs, "s", out value); } var enabled = value != 0; var isProfilePhysics = TryGetArgs <int>(cmdargs, "p", out value); var profilePhysics = value != 0; var isProfileGpu = TryGetArgs <int>(cmdargs, "g", out value); var profileGpu = value != 0; //profilegpu is only valid on client profileGpu = !SharedConfig.IsServer && profileGpu; var isLog = TryGetArgs <int>(cmdargs, "l", out value); var enableLog = !isLog || value != 0; if (isProfilePhysics) { #if PHYSICS_PROFILER_STATISTICS UnityEngine.Profiling.Profiler.profilePhysics = profilePhysics; #endif result = "ok"; } if (isClient && !SharedConfig.IsServer || isServer && SharedConfig.IsServer) { if (enabled) { UnityProfiler.EnableProfiler(profileGpu, enableLog); result = String.Format("ok, start {0}", SharedConfig.IsServer ? "server" : "client"); } else { UnityProfiler.DisableProfiler(); result = "ok, stop profiler"; } } else if (isProfileGpu) { UnityProfiler.EnableProfileGpu(profileGpu); } result = String.Format("{0} profile gpu {1} profile physics {2}", result, profileGpu ? "enabled" : "disabled", profilePhysics ? "enabled" : "disabled"); if (isServer && isProfileGpu) { result = "GPU Profile is not supported on Server!."; } break; } } return(result); }
IEnumerator Start() { Log4ConfigManager.InitLog4net(); Application.logMessageReceived += UnityLogCapturer.ApplicationOnLogMessageReceived; #if !UNITY_EDITOR BootArg = new string[0]; #endif if (null == BootArg) { BootArg = new string[0]; } var bootCmd = CmdParser.ParseCommandLine(BootArg.Length != 0 ? BootArg : System.Environment.GetCommandLineArgs()); QualitySettings.shadowDistance = 120; PlayerPrefs.DeleteKey("unity_server_mode"); _isDestroy = false; var hallController = GetHallController(); if (hallController == null) { #if UNITY_EDITOR SharedConfig.IsOffline = Offline; SharedConfig.IsRobot = IsRobot; SharedConfig.MutilThread = !DisableMutilThread; SharedConfig.DisableDoor = DisableDoor; #endif SharedConfig.InitConfigBootArgs(bootCmd); } else { SharedConfig.IsOffline = false; } SharedConfig.IsServer = false; // 删除是否服务器数据 _logger = new LoggerAdapter(typeof(ClientGameController)); RegisterClientCallback(); InitPhysicsSimulation(); InitCamera(); ComponentAllocateManager.Instance.Init(); if (hallController == null) { _assetLoader = new AssetPool(this); yield return(StartCoroutine(_assetLoader.Init(SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.Resource, SharedConfig.IsServer))); DoStart(); } else { _assetLoader = AssetPool.Instance; HallUtility.GetGameClientInfo(); _logger.InfoFormat("GetGameClientInfo..."); } MyHttpServer.Start(SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.HttpPort, _clientRoom); #if UNITY_SOURCE_MODIFIED && !UNITY_EDITOR if (!SharedConfig.InSamplingMode && !SharedConfig.InLegacySampleingMode) { UnityProfiler.EnableProfiler(true); } #endif }