Refactor Remote Play

This commit is contained in:
redphx 2024-09-19 18:01:27 +07:00
parent 34f959d5ae
commit ec1805f832
2 changed files with 43 additions and 47 deletions

View File

@ -53,48 +53,6 @@ export class RemotePlayManager {
private consoles!: Array<RemotePlayConsole>; private consoles!: Array<RemotePlayConsole>;
private regions: Array<RemotePlayRegion> = []; private regions: Array<RemotePlayRegion> = [];
static readonly BASE_DEVICE_INFO = {
appInfo: {
env: {
clientAppId: window.location.host,
clientAppType: 'browser',
clientAppVersion: '24.17.36',
clientSdkVersion: '10.1.14',
httpEnvironment: 'prod',
sdkInstallId: '',
},
},
dev: {
displayInfo: {
dimensions: {
widthInPixels: 1920,
heightInPixels: 1080,
},
pixelDensity: {
dpiX: 1,
dpiY: 1,
},
},
hw: {
make: 'Microsoft',
model: 'unknown',
sdktype: 'web',
},
os: {
name: 'windows',
ver: '22631.2715',
platform: 'desktop',
},
browser: {
browserName: 'chrome',
browserVersion: '125.0',
},
},
};
constructor() {
}
initialize() { initialize() {
if (this.isInitialized) { if (this.isInitialized) {
return; return;
@ -206,11 +164,9 @@ export class RemotePlayManager {
// Store working server // Store working server
STATES.remotePlay.server = region.baseUri; STATES.remotePlay.server = region.baseUri;
} catch (e) {}
if (this.consoles) {
break; break;
} } catch (e) {}
} }
// None of the servers worked // None of the servers worked
@ -270,7 +226,7 @@ export class RemotePlayManager {
} }
} }
private isReady() { isReady() {
return this.consoles !== null; return this.consoles !== null;
} }
} }

View File

@ -12,6 +12,46 @@ import { RemotePlayManager } from "@/modules/remote-play-manager";
export class XhomeInterceptor { export class XhomeInterceptor {
static #consoleAddrs: RemotePlayConsoleAddresses = {}; static #consoleAddrs: RemotePlayConsoleAddresses = {};
private static readonly BASE_DEVICE_INFO = {
appInfo: {
env: {
clientAppId: window.location.host,
clientAppType: 'browser',
clientAppVersion: '24.17.36',
clientSdkVersion: '10.1.14',
httpEnvironment: 'prod',
sdkInstallId: '',
},
},
dev: {
displayInfo: {
dimensions: {
widthInPixels: 1920,
heightInPixels: 1080,
},
pixelDensity: {
dpiX: 1,
dpiY: 1,
},
},
hw: {
make: 'Microsoft',
model: 'unknown',
sdktype: 'web',
},
os: {
name: 'windows',
ver: '22631.2715',
platform: 'desktop',
},
browser: {
browserName: 'chrome',
browserVersion: '125.0',
},
},
};
static async #handleLogin(request: Request) { static async #handleLogin(request: Request) {
try { try {
const clone = (request as Request).clone(); const clone = (request as Request).clone();
@ -149,7 +189,7 @@ export class XhomeInterceptor {
headers.authorization = `Bearer ${RemotePlayManager.getInstance().xhomeToken}`; headers.authorization = `Bearer ${RemotePlayManager.getInstance().xhomeToken}`;
// Patch resolution // Patch resolution
const deviceInfo = RemotePlayManager.BASE_DEVICE_INFO; const deviceInfo = XhomeInterceptor.BASE_DEVICE_INFO;
if (getPref(PrefKey.REMOTE_PLAY_RESOLUTION) === StreamResolution.DIM_720P) { if (getPref(PrefKey.REMOTE_PLAY_RESOLUTION) === StreamResolution.DIM_720P) {
deviceInfo.dev.os.name = 'android'; deviceInfo.dev.os.name = 'android';
} }