mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
Set up the dumbest HTTP server
This commit is contained in:
parent
3921e80831
commit
53f828674a
3 changed files with 15 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "../bsnes.hpp"
|
||||
|
||||
#include "platform.cpp"
|
||||
#include "game.cpp"
|
||||
#include "game-pak.cpp"
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
};
|
||||
|
||||
ProducerConsumerQueue<RpcCommand> pendingRpcCommands;
|
||||
nall::thread rpcHandlerThread;
|
||||
nall::HTTP::Server rpcServer;
|
||||
|
||||
bool fastForwarding = false;
|
||||
bool rewinding = false;
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
#include <debugapi.h>
|
||||
|
||||
auto Program::startRpcListener() -> void {
|
||||
// NB: There is no cross-platform way to read from a pipe in a non-blocking
|
||||
// way. So instead, we're going to spin up a blocking thread that reads stdin
|
||||
// and processes it. What's even worse, is that we can't even properly
|
||||
// terminate this thread since there's no timeout on blocking stdin reads,
|
||||
// all we can do is force-terminate this thread on exit.
|
||||
rpcHandlerThread = nall::thread::create([&](auto param) {
|
||||
OutputDebugStringA("HELLO IT WORKED LOOK AT THIS\n");
|
||||
rpcServer.main([&](nall::HTTP::Request& rq) -> nall::HTTP::Response {
|
||||
OutputDebugStringA("GOT REQUEST\n");
|
||||
nall::HTTP::Response resp;
|
||||
|
||||
resp.setResponseType(200);
|
||||
resp.setText("hooray!");
|
||||
resp.header.append("Content-Type", "text/plain");
|
||||
return resp;
|
||||
});
|
||||
|
||||
OutputDebugStringA("SETTING UP SERVER\n");
|
||||
rpcServer.open();
|
||||
}
|
||||
|
||||
auto Program::stopRpcListener() -> void {
|
||||
rpcHandlerThread.cancel();
|
||||
rpcServer.close();
|
||||
}
|
||||
|
||||
auto Program::processRpcCommands() -> void {
|
||||
rpcServer.scan();
|
||||
}
|
Loading…
Add table
Reference in a new issue