I am trying to develop a Unity project that makes use of the Battle Simulator, but am running into a number of problems.
I stumbled into another thread which recommends running the simulator as a sub process within C#, and feeding commands in through stdin and reading from the process's stdout. I first tried running the simulator process within C# on a separate thread, feeding in commands with a thread safe q and then trying to read the output, but the problem is all the output is going to stdout. What this has meant is that I can only read that output once -- I want to run the app by feeding a command and then getting a single response and reading that, but with everything going to stdout it won't let me read it multiple times, nor will it let me start the stream over. Here is a more thorough explanation of the problem and some code samples: https://stackoverflow.com/questions...out-from-process-in-c-accessing-multiple-time
What I've tried to do now instead then is avoid using stdin/out completely, and instead run the simulator on a JS localhost server and simply make an express web API. The idea is to post inputs from unity, then get those inputs from the API, then post a response. The problem with THIS however is that the simulator returns the response in separate strings, and when I make an API request the response I get only comes in one string at a time from the BattleStream. The code I have looks similar to the example in the battle sim docs just with the async read placed into the express definition instead of as an async function running in the background, meaning it will run when you make an API request. But it is not reading all of the response, only one string at a time! I cannot figure out a way forward with this since I am somewhat inexperienced with JS.
Basically the problem is that I want to run the simulator for the duration of my Unity project and treat it as a request and response thing, but everything I'm doing and even parts of what I've read online from my interpretation make it seem like I have to feed in all commands then can only read output at the end of something. Any suggestions how to move forward with this / what the best approach would be?
I stumbled into another thread which recommends running the simulator as a sub process within C#, and feeding commands in through stdin and reading from the process's stdout. I first tried running the simulator process within C# on a separate thread, feeding in commands with a thread safe q and then trying to read the output, but the problem is all the output is going to stdout. What this has meant is that I can only read that output once -- I want to run the app by feeding a command and then getting a single response and reading that, but with everything going to stdout it won't let me read it multiple times, nor will it let me start the stream over. Here is a more thorough explanation of the problem and some code samples: https://stackoverflow.com/questions...out-from-process-in-c-accessing-multiple-time
What I've tried to do now instead then is avoid using stdin/out completely, and instead run the simulator on a JS localhost server and simply make an express web API. The idea is to post inputs from unity, then get those inputs from the API, then post a response. The problem with THIS however is that the simulator returns the response in separate strings, and when I make an API request the response I get only comes in one string at a time from the BattleStream. The code I have looks similar to the example in the battle sim docs just with the async read placed into the express definition instead of as an async function running in the background, meaning it will run when you make an API request. But it is not reading all of the response, only one string at a time! I cannot figure out a way forward with this since I am somewhat inexperienced with JS.
Basically the problem is that I want to run the simulator for the duration of my Unity project and treat it as a request and response thing, but everything I'm doing and even parts of what I've read online from my interpretation make it seem like I have to feed in all commands then can only read output at the end of something. Any suggestions how to move forward with this / what the best approach would be?