Merge pull request #17520 from Nemoumbra/websocket-client

Added WebsocketClientInfo
This commit is contained in:
Henrik Rydgård 2023-05-30 08:11:35 +02:00 committed by GitHub
commit 69b5b36416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -138,6 +138,8 @@ void HandleDebuggerRequest(const http::Request &request) {
UpdateConnected(1);
SetupDebuggerLock();
WebSocketClientInfo client_info;
GameBroadcaster game;
LogBroadcaster logger;
InputBroadcaster input;
@ -166,7 +168,7 @@ void HandleDebuggerRequest(const http::Request &request) {
return;
}
DebuggerRequest req(event, ws, root);
DebuggerRequest req(event, ws, root, &client_info);
auto eventFunc = eventHandlers.find(event);
if (eventFunc != eventHandlers.end()) {
std::lock_guard<std::mutex> guard(lifecycleLock);

View File

@ -96,6 +96,18 @@ void WebSocketGameStatus(DebuggerRequest &req) {
// - version: string, typically starts with "v" and may have git build info.
void WebSocketVersion(DebuggerRequest &req) {
JsonWriter &json = req.Respond();
std::string version;
if (!req.ParamString("version", &version)) {
return;
}
std::string name;
if (!req.ParamString("name", &name)) {
return;
}
req.client->name = name;
req.client->version = version;
json.writeString("name", "PPSSPP");
json.writeString("version", PPSSPP_GIT_VERSION);
}

View File

@ -33,6 +33,14 @@
using namespace json;
struct WebSocketClientInfo {
WebSocketClientInfo() : name(), version() {
}
std::string name;
std::string version;
};
struct DebuggerErrorEvent {
DebuggerErrorEvent(const std::string m, LogTypes::LOG_LEVELS l, const JsonGet data = JsonValue(JSON_NULL))
: message(m), level(l) {
@ -70,13 +78,14 @@ enum class DebuggerParamType {
};
struct DebuggerRequest {
DebuggerRequest(const char *n, net::WebSocketServer *w, const JsonGet &d)
: name(n), ws(w), data(d) {
DebuggerRequest(const char *n, net::WebSocketServer *w, const JsonGet &d, WebSocketClientInfo *client_info)
: name(n), ws(w), data(d), client(client_info) {
}
const char *name;
net::WebSocketServer *ws;
const JsonGet data;
WebSocketClientInfo *client;
void Fail(const std::string &message) {
ws->Send(DebuggerErrorEvent(message, LogTypes::LERROR, data));