public void HandleRequest(HttpListenerContext context) { lock (_modStatusLock) { var req = context.Request; var resp = context.Response; try { #if EMULATOR /*THIS IS TEST CODE FOR EMULATOR*/ resp.SerializeOk(new ModSetupStatus() { IsBeatSaberInstalled = true, CurrentStatus = ModSetupStatusType.ModInstalled }); return; #else var model = new ModSetupStatus() { IsBeatSaberInstalled = _mod.IsBeatSaberInstalled }; if (model.IsBeatSaberInstalled) { if (_mod.IsInstalledBeatSaberModded) { model.CurrentStatus = ModSetupStatusType.ModInstalled; } else if (!_mod.IsBeatSaberInstalled && _mod.DoesTempApkExist) { if (_mod.IsTempApkModded) { model.CurrentStatus = ModSetupStatusType.ReadyForInstall; } else { model.CurrentStatus = ModSetupStatusType.ReadyForModApply; } } } else { if (_mod.DoesTempApkExist) { if (_mod.IsTempApkModded) { model.CurrentStatus = ModSetupStatusType.ReadyForInstall; } else { model.CurrentStatus = ModSetupStatusType.ReadyForModApply; } } } resp.SerializeOk(model); #endif } catch (Exception ex) { Log.LogErr("Exception handling mod status!", ex); resp.StatusCode = 500; } } }
public void HandleRequest(HttpListenerContext context) { lock (_modStatusLock) { var req = context.Request; var resp = context.Response; try { #if EMULATOR /*THIS IS TEST CODE FOR EMULATOR*/ resp.SerializeOk(new ModSetupStatus() { IsBeatSaberInstalled = true, CurrentStatus = ModSetupStatusType.ModInstalled }); return; #else try { _mod.CheckCreateModdedBackup(); } catch (Exception ex) { Log.LogErr($"what? I shouldn't get an exception from this here.", ex); } var model = new ModSetupStatus() { IsBeatSaberInstalled = _mod.IsBeatSaberInstalled, BeatOnVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), HasGoodBackup = _mod.GetHasGoodBackup(), HasHalfAssBackup = _mod.GetHasCrapBackup() }; if (model.IsBeatSaberInstalled) { if (_mod.IsInstalledBeatSaberModded) { model.CurrentStatus = ModSetupStatusType.ModInstalled; } else if (!_mod.IsBeatSaberInstalled && _mod.DoesTempApkExist) { if (_mod.IsTempApkModded) { model.CurrentStatus = ModSetupStatusType.ReadyForInstall; } else { model.CurrentStatus = ModSetupStatusType.ReadyForModApply; } } } else { if (_mod.DoesTempApkExist) { if (_mod.IsTempApkModded) { model.CurrentStatus = ModSetupStatusType.ReadyForInstall; } else { model.CurrentStatus = ModSetupStatusType.ReadyForModApply; } } } resp.SerializeOk(model); #endif } catch (Exception ex) { Log.LogErr("Exception handling mod status!", ex); resp.StatusCode = 500; } } }