Add a command-line parameter for the RPC server

This commit is contained in:
Anaïs Betts 2022-01-09 22:39:46 +01:00
parent a302403700
commit 250b391696
3 changed files with 13 additions and 5 deletions

View File

@ -30,6 +30,8 @@ auto nall::main(Arguments arguments) -> void {
Application::locale().select(argument.trimLeft("--locale=", 1L));
} else if(argument.beginsWith("--settings=")) {
settings.location = argument.trimLeft("--settings=", 1L);
} else if(argument.beginsWith("--rpcPort=")) {
program.rpcServerPort = std::stoi(std::string(argument.trimLeft("--rpcPort=").data()));
} else if (inode::exists(argument)) {
//game without option
program.gameQueue.append({"Auto;", argument});

View File

@ -225,6 +225,7 @@ public:
ProducerConsumerQueue<RpcCommand> pendingRpcCommands;
nall::HTTP::Server rpcServer;
int rpcServerPort = 0;
bool fastForwarding = false;
bool rewinding = false;

View File

@ -1,6 +1,8 @@
#include <debugapi.h>
auto Program::startRpcListener() -> void {
if (rpcServerPort < 1024) return;
rpcServer.main([&](nall::HTTP::Request &rq) -> nall::HTTP::Response {
nall::HTTP::Response resp;
@ -46,14 +48,17 @@ auto Program::startRpcListener() -> void {
return resp;
});
rpcServer.open();
rpcServer.open(rpcServerPort);
}
auto Program::stopRpcListener() -> void {
if (rpcServerPort < 1024) return;
rpcServer.close();
}
auto Program::processRpcCommands() -> void {
if (rpcServerPort < 1024) return;
rpcServer.scan();
RpcCommand cmd;