Skip to content

Commit

Permalink
[XLiveAPI] Added DeleteSessionsByMac endpoint
Browse files Browse the repository at this point in the history
Delete sessions by mac when host or guest crashes.
  • Loading branch information
AdrianCassar committed Dec 24, 2023
1 parent 9c6068e commit ddf88c0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ It should also be noted that due to the way Steam Decks handle configuration, yo
| GRID | |
| GTA V Beta | Requires ```protect_zero = false``` or use patches. | [Beta Showcase](https://www.youtube.com/watch?v=nIjZ7sRGZlo), [Beta Showcase](https://www.youtube.com/watch?v=YIBjy5ZJcq4) | [TU 13](https://github.com/AdrianCassar/Xenia-WebServices/blob/main/patches/545408A7%20-%20Grand%20Theft%20Auto%20V%20(TU13).patch.toml), [TU 10](https://github.com/AdrianCassar/Xenia-WebServices/blob/main/patches/545408A7%20-%20Grand%20Theft%20Auto%20V%20(TU10).patch.toml) |
| GTA V TU 2-13 | Must complete prologue, download gamesave [here](https://cdn.discordapp.com/attachments/641360906495983616/1101132116441440366/545408A7.rar). Unstable and often crashes. | [Solo Session](https://www.youtube.com/watch?v=lap7liW6pco) |
| Guilty Gear 2: Overture | |
| Gundam Operation Troy | [English Patch](https://github.com/Eight-Mansions/MSGOT/releases)
| Halo 3 ODST v13.2 using [Sunrise Server](https://github.com/ahnewark/Sunrise-Halo3-WebServices) | Mousehook | [Head to Head](https://www.youtube.com/watch?v=amS8OxH3exs) | [Halo 3 Patch](https://github.com/AdrianCassar/Xenia-WebServices/blob/main/patches/4D5307E6%20-%20Halo%203.patch.toml)
| Juiced 2 | |
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/app/xenia_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ void EmulatorApp::OnDestroy() {
}

// Delete sessions on shutdown.
xe::kernel::XLiveAPI::DeleteAllSessions();
xe::kernel::XLiveAPI::DeleteAllSessionsByMac();

curl_global_cleanup();
#pragma endregion
Expand Down
3 changes: 3 additions & 0 deletions src/xenia/emulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "xenia/hid/input_driver.h"
#include "xenia/hid/input_system.h"
#include "xenia/kernel/kernel_state.h"
#include "xenia/kernel/XLiveAPI.h"
#include "xenia/kernel/user_module.h"
#include "xenia/kernel/util/gameinfo_utils.h"
#include "xenia/kernel/util/xdbf_utils.h"
Expand Down Expand Up @@ -797,6 +798,8 @@ bool Emulator::ExceptionCallback(Exception* ex) {
});
}

xe::kernel::XLiveAPI::DeleteAllSessionsByMac();

// Now suspend ourself (we should be a guest thread).
current_thread->Suspend(nullptr);

Expand Down
2 changes: 2 additions & 0 deletions src/xenia/gpu/graphics_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "xenia/ui/graphics_provider.h"
#include "xenia/ui/window.h"
#include "xenia/ui/windowed_app_context.h"
#include "xenia/kernel/XLiveAPI.h"
#include "xenia/kernel/kernel_state.h"
DEFINE_bool(
store_shaders, true,
Expand Down Expand Up @@ -193,6 +194,7 @@ void GraphicsSystem::OnHostGpuLossFromAnyThread(
if (host_gpu_loss_reported_.test_and_set(std::memory_order_relaxed)) {
return;
}
xe::kernel::XLiveAPI::DeleteAllSessionsByMac();
xe::FatalError("Graphics device lost (probably due to an internal error)");
}

Expand Down
20 changes: 16 additions & 4 deletions src/xenia/kernel/XLiveAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void XLiveAPI::Init() {
initialized_ = true;

// Delete sessions on start-up.
XLiveAPI::DeleteAllSessions();
DeleteAllSessions();
}

void XLiveAPI::clearXnaddrCache() {
Expand Down Expand Up @@ -1012,10 +1012,10 @@ void XLiveAPI::DeleteSession(xe::be<uint64_t> sessionId) {
qos_payload_cache.erase(sessionId);
}

void XLiveAPI::DeleteAllSessions() {
void XLiveAPI::DeleteAllSessionsByMac() {
if (!is_active()) return;
std::string endpoint =

const std::string endpoint =
fmt::format("DeleteSessions/{:012x}", MacAddresstoUint64(mac_address));

memory chunk = Delete(endpoint);
Expand All @@ -1025,6 +1025,18 @@ void XLiveAPI::DeleteAllSessions() {
}
}

void XLiveAPI::DeleteAllSessions() {
if (!is_active()) return;

const std::string endpoint = fmt::format("DeleteSessions");

memory chunk = Delete(endpoint);

if (chunk.http_code != 200) {
XELOGI("Failed to delete all sessions");
}
}

void XLiveAPI::XSessionCreate(xe::be<uint64_t> sessionId, XSesion* data) {
std::string endpoint =
fmt::format("title/{:08X}/sessions", kernel_state()->title_id());
Expand Down
2 changes: 2 additions & 0 deletions src/xenia/kernel/XLiveAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ class XLiveAPI {

static void DeleteSession(xe::be<uint64_t> sessionId);

static void DeleteAllSessionsByMac();

static void DeleteAllSessions();

static void XSessionCreate(xe::be<uint64_t> sessionId, XSesion* data);
Expand Down

0 comments on commit ddf88c0

Please sign in to comment.