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,10 +30,12 @@ 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(inode::exists(argument)) {
} 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});
} else if(argument.find(";")) {
} else if (argument.find(";")) {
//game with option
auto game = argument.split(";", 1L);
if(inode::exists(game.last())) program.gameQueue.append(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,7 +1,9 @@
#include <debugapi.h>
auto Program::startRpcListener() -> void {
rpcServer.main([&](nall::HTTP::Request& rq) -> nall::HTTP::Response {
if (rpcServerPort < 1024) return;
rpcServer.main([&](nall::HTTP::Request &rq) -> nall::HTTP::Response {
nall::HTTP::Response resp;
if (rq.requestType() != nall::HTTP::Request::RequestType::Post) {
@ -43,17 +45,20 @@ auto Program::startRpcListener() -> void {
return true;
});
return resp;
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;