private void Start() { listenAddress = FindNetworkAddress(); if (listenAddress == null) { Debug.LogWarning("[REMOTE] Failed to find an address to listen on"); return; } Debug.Log("[REMOTE] Listening for commands on address " + listenAddress + ":" + port); try { commandManager = new ConsoleCommandManager(); listener = new TcpListener(listenAddress, port); listener.Start(); } catch (SocketException e) { Debug.LogError("[REMOTE] Socket exception: " + e); if (listener != null) { listener.Stop(); } } }
private void LoadAvailableConsoleCommands() { //commandParamValues = new Dictionary<string, Dictionary<ParameterInfo, object>>(); Debug.Log("Creating"); hideFlags = HideFlags.HideAndDontSave; commands = new Commands(); commandManager = new ConsoleCommandManager(); foreach (var command in commandManager.ConsoleCommandMap) { CommandData data = new CommandData(command.Key); foreach (var parameter in command.Value.GetParameters()) { ParamValue paramVal = new ParamValue(); paramVal.type = parameter.ParameterType.Name; paramVal.Value = parameter.ParameterType.IsValueType ? Activator.CreateInstance(parameter.ParameterType) : null; data.ParamValues.Add(paramVal); } commands.AddCommandData(data); } }
private void OnGUI() { if (commandManager == null) { Debug.Log("Recreating commandmanager"); commandManager = new ConsoleCommandManager(); } foreach (var command in commandManager.ConsoleCommandMap) { EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(command.Key); EditorGUILayout.LabelField("signature: " + GetMethodSignature(command.Value)); foreach (var parameter in command.Value.GetParameters()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(parameter.Name + ": "); UpdatePropertyValue(command.Key, parameter); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Send")) { using (TcpClient client = new TcpClient()) { client.Connect("192.168.1.107", 64064); using (var stream = client.GetStream()) { string message = GetCommandString(command.Key); byte[] buffer = Encoding.UTF8.GetBytes(message); Debug.Log("Sending: " + message); stream.Write(buffer, 0, buffer.Length); stream.Close(); } } } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); } }
private void LoadAvailableConsoleCommands() { commandManager = new ConsoleCommandManager(); }