Closed cokll closed 3 years ago
Your issue title asks how to remove console input but your description suggests you're already unable to enter commands. Please specifically state what the issue you're facing is and describe reproduction steps.
I use the pipeline to start TShock,I sent any instructions to TShock that did not respond. In 1.3.4.4 I removed IsInputRedirected to use the instruction,But 1.3.5.3 I did not find a similar one.
if (Console.IsInputRedirected == true) { Console.WriteLine("TerrariaServer is running in the background and input is disabled."); return; }
@Ijwu so?
I apologize for the delay @cokll. To be honest, I've shared this issue with the dev team and we collectively acknowledge that we have no idea what you're asking.
Feel free to get more specific or discuss your expected result.
In 1.3.4.4 there are Console.IsInputRedirected,But 1.3.5.3 I did not find a similar one. @Ijwu
Why you are still asking for Console.IsInputRedirected
?
From what you said
In 1.3.4.4 I removed IsInputRedirected to use the instruction
You just want the TShock send you an instruction like TerrariaServer is running in the background and input is disabled.
?
@mistzzt I want to delete IsInputRedirected,I don't want the input to be disabled in the background.
@mistzzt I made a software to manage TShock.If the input is disabled, the status can not be obtained
@cokll I'm trying to understand what you are asking, are you trying to use System.Diagnostics.Process
to wrap the TShock binary and now it's not working for you ?
Maybe he is asking "how to redirect own text to TShock's console by using pipeline, as if that was typed on console", I guess.
As you developers know, before TShock Mintaka (4.3.21), TerrariaServerAPI/Terraria/Main.cs
had the following part:
public static void startDedInput()
{
if (Console.IsInputRedirected == true)
{
Console.WriteLine("TerrariaServer is running in the background and input is disabled.");
return;
}
Thread t = new Thread(Main.startDedInputCallBack);
t.Name = "Console Input Thread";
t.IsBackground = true;
t.Start();
}
public static void startDedInputCallBack(object threadContext)
{
while (!Netplay.disconnect)
{
Console.Write(": ");
string str = Console.ReadLine();
......
Removing the part he said will probably make it possible to use a way like this:
$ mkfifo /tmp/pipe
$ mono TerrariaServer.exe -world my.wld < /tmp/pipe &
$ echo "bc hello" > /tmp/pipe
$ echo "kick badguy" > /tmp/pipe
$ echo "restart" > /tmp/pipe
But now, vanilla part of Terraria is hidden into OTAPI, so people can't hack that easily.
I recommend using REST API instead, or making custom plugin which captures Console.ReadLine()
in some way, or whatever (not sure).
Or perhaps the OTAPI 'startDedInput' hook can be used to run the required code as like premintaka
@OnsenManju Yes,So it can not be modified now.
Closing tentatively based on above feedback. Reopen if this is still an issue
I'm not at all convince this is fixed: we got a report in #2003 that says that they want input redirection enabled and then again in Discord. I'm not sure entirely what @bskrtich was referring to other than I think he was wanting it to not crash as per #1487. I think the end solution is going to be having a command line flag to enable or disable input redirection.
@hakusaro Correct, the issue I was talking about was the crash fixed by #1487
Holy guacamole, you're alive! Thank you for the context! 💚
hah! I am! Have to keep my docker container for tshock/vanilla server working. Happy I could help!
Hey There, in my case I'm running TShock as a python subprocess. I can write to the stdin stream but because of "TerrariaServer is running in the background and input is disabled" nothing happens.
If it's not possible to make a flag to disable the background mode. How can I trick mono into thinking, that the process is running in the foreground?
Thanks for your help!
This is a really reasonable request. Definitely reasonable and definitely something we'd want to get fixed, @dr4xor.
See the feature description by Onsen below. --@hakusaro