-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debugger: Organize WebSocket event handling.
Just a starting point to organize it. Trying to keep it simple.
- Loading branch information
1 parent
e681379
commit 653ae78
Showing
12 changed files
with
412 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2018- PPSSPP Project. | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 2.0 or later versions. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License 2.0 for more details. | ||
|
||
// A copy of the GPL 2.0 should have been included with the program. | ||
// If not, see http://www.gnu.org/licenses/ | ||
|
||
// Official git repository and contact information can be found at | ||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include "ext/vjson/json.h" | ||
#include "json/json_writer.h" | ||
#include "net/websocket_server.h" | ||
#include "Common/Log.h" | ||
|
||
struct DebuggerErrorEvent { | ||
DebuggerErrorEvent(const std::string m, LogTypes::LOG_LEVELS l) : message(m), level(l) { | ||
} | ||
|
||
std::string message; | ||
LogTypes::LOG_LEVELS level; | ||
|
||
operator std::string() { | ||
JsonWriter j; | ||
j.begin(); | ||
j.writeString("event", "error"); | ||
j.writeString("message", message); | ||
j.writeInt("level", level); | ||
j.end(); | ||
return j.str(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2018- PPSSPP Project. | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 2.0 or later versions. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License 2.0 for more details. | ||
|
||
// A copy of the GPL 2.0 should have been included with the program. | ||
// If not, see http://www.gnu.org/licenses/ | ||
|
||
// Official git repository and contact information can be found at | ||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
|
||
#include "Core/Debugger/WebSocket/Common.h" | ||
#include "Core/Debugger/WebSocket/GameBroadcaster.h" | ||
#include "Core/System.h" | ||
|
||
void GameBroadcaster::Broadcast(net::WebSocketServer *ws) { | ||
// TODO: This is ugly. Implement proper information instead. | ||
// TODO: Should probably include info about which game, etc. | ||
GlobalUIState state = GetUIState(); | ||
if (prevState_ != state) { | ||
if (state == UISTATE_PAUSEMENU) { | ||
ws->Send(R"({"event":"game_pause"})"); | ||
} else if (state == UISTATE_INGAME && prevState_ == UISTATE_PAUSEMENU) { | ||
ws->Send(R"({"event":"game_resume"})"); | ||
} else if (state == UISTATE_INGAME) { | ||
ws->Send(R"({"event":"game_start"})"); | ||
} else if (state == UISTATE_MENU) { | ||
ws->Send(R"({"event":"game_quit"})"); | ||
} | ||
prevState_ = state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2018- PPSSPP Project. | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 2.0 or later versions. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License 2.0 for more details. | ||
|
||
// A copy of the GPL 2.0 should have been included with the program. | ||
// If not, see http://www.gnu.org/licenses/ | ||
|
||
// Official git repository and contact information can be found at | ||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
|
||
#pragma once | ||
|
||
#include "Core/System.h" | ||
|
||
namespace net { | ||
class WebSocketServer; | ||
} | ||
|
||
struct GameBroadcaster { | ||
public: | ||
GameBroadcaster() { | ||
prevState_ = GetUIState(); | ||
} | ||
|
||
void Broadcast(net::WebSocketServer *ws); | ||
|
||
private: | ||
GlobalUIState prevState_; | ||
}; |
Oops, something went wrong.