mirror of https://github.com/bsnes-emu/bsnes.git
Add a command-line parameter for the RPC server
This commit is contained in:
parent
a302403700
commit
250b391696
|
@ -30,10 +30,12 @@ auto nall::main(Arguments arguments) -> void {
|
||||||
Application::locale().select(argument.trimLeft("--locale=", 1L));
|
Application::locale().select(argument.trimLeft("--locale=", 1L));
|
||||||
} else if(argument.beginsWith("--settings=")) {
|
} else if(argument.beginsWith("--settings=")) {
|
||||||
settings.location = argument.trimLeft("--settings=", 1L);
|
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
|
//game without option
|
||||||
program.gameQueue.append({"Auto;", argument});
|
program.gameQueue.append({"Auto;", argument});
|
||||||
} else if(argument.find(";")) {
|
} else if (argument.find(";")) {
|
||||||
//game with option
|
//game with option
|
||||||
auto game = argument.split(";", 1L);
|
auto game = argument.split(";", 1L);
|
||||||
if(inode::exists(game.last())) program.gameQueue.append(argument);
|
if(inode::exists(game.last())) program.gameQueue.append(argument);
|
||||||
|
|
|
@ -225,6 +225,7 @@ public:
|
||||||
|
|
||||||
ProducerConsumerQueue<RpcCommand> pendingRpcCommands;
|
ProducerConsumerQueue<RpcCommand> pendingRpcCommands;
|
||||||
nall::HTTP::Server rpcServer;
|
nall::HTTP::Server rpcServer;
|
||||||
|
int rpcServerPort = 0;
|
||||||
|
|
||||||
bool fastForwarding = false;
|
bool fastForwarding = false;
|
||||||
bool rewinding = false;
|
bool rewinding = false;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include <debugapi.h>
|
#include <debugapi.h>
|
||||||
|
|
||||||
auto Program::startRpcListener() -> void {
|
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;
|
nall::HTTP::Response resp;
|
||||||
|
|
||||||
if (rq.requestType() != nall::HTTP::Request::RequestType::Post) {
|
if (rq.requestType() != nall::HTTP::Request::RequestType::Post) {
|
||||||
|
@ -43,17 +45,20 @@ auto Program::startRpcListener() -> void {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
|
|
||||||
rpcServer.open();
|
rpcServer.open(rpcServerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Program::stopRpcListener() -> void {
|
auto Program::stopRpcListener() -> void {
|
||||||
|
if (rpcServerPort < 1024) return;
|
||||||
rpcServer.close();
|
rpcServer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Program::processRpcCommands() -> void {
|
auto Program::processRpcCommands() -> void {
|
||||||
|
if (rpcServerPort < 1024) return;
|
||||||
|
|
||||||
rpcServer.scan();
|
rpcServer.scan();
|
||||||
|
|
||||||
RpcCommand cmd;
|
RpcCommand cmd;
|
||||||
|
|
Loading…
Reference in New Issue