public void SendCommand(AvorionServerCommand command) { switch (command.ExecutionType) { case CommandExecutionTypes.Lua: SendLuaCommand(command); break; case CommandExecutionTypes.Console: StringBuilder tmpCommandBuilder = new StringBuilder(); tmpCommandBuilder.Append(command.InternalName); if (command.HasParameters) { foreach (AvorionServerCommandParameter currentParameter in command.Parameters) { tmpCommandBuilder.Append(" "); tmpCommandBuilder.Append(currentParameter.Prefix); tmpCommandBuilder.Append(" "); tmpCommandBuilder.Append(currentParameter.Content); } } SendConsoleCommand(tmpCommandBuilder.ToString()); break; default: break; } }
public static AvorionServerCommand DequeueCommand() { AvorionServerCommand result = null; if (_commandsToExecute.Count > 0) { result = _commandsToExecute.Dequeue(); } return(result); }
public HttpResponseMessage Post([FromBody] AvorionServerCommand value) { CommandsApiData.AddCommand(value); var resp = new HttpResponseMessage(HttpStatusCode.OK); StringBuilder resultBuilder = new StringBuilder(); resultBuilder.Append("Success"); resp.Content = new StringContent(resultBuilder.ToString(), System.Text.Encoding.UTF8, "text/plain"); return(resp); }
private void ProcessCommandRequest() { AvorionServerCommand tmpCommand = CommandsApiData.DequeueCommand(); if (tmpCommand != null) { Server.SendCommand(tmpCommand); } else { _process.StandardInput.WriteLine(-1); } }
private void SendLuaCommand(AvorionServerCommand command) { Process.StandardInput.WriteLine(command.InternalId); if (command.HasParameters) { foreach (AvorionServerCommandParameter currentParameter in command.Parameters) { byte[] buffer = System.Text.Encoding.UTF8.GetBytes(currentParameter.Content); Process.StandardInput.BaseStream.Write(buffer, 0, buffer.Length); Process.StandardInput.WriteLine(); } } }
public static void AddCommand(AvorionServerCommand command) { switch (command.ExecutionType) { case CommandExecutionTypes.Lua: _commandsToExecute.Enqueue(command); break; case CommandExecutionTypes.Console: ManagerController.Server.SendCommand(command); break; default: break; } }
public void AddCommand(AvorionServerCommand command) { // CommandsApiData.AddCommand(command); Server.SendCommand(command); }