mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Get PointerServer's port from the app
This commit is contained in:
parent
0d59ab2ee2
commit
a3a7a57b51
@ -314,7 +314,10 @@ function main() {
|
||||
}
|
||||
|
||||
// Start PointerProviderServer
|
||||
(getPref(PrefKey.MKB_ENABLED)) && AppInterface && AppInterface.startPointerServer();
|
||||
if (getPref(PrefKey.MKB_ENABLED) && AppInterface) {
|
||||
STATES.pointerServerPort = AppInterface.startPointerServer() || 9269;
|
||||
BxLogger.info('startPointerServer', 'Port', STATES.pointerServerPort.toString());
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -33,7 +33,7 @@ class WebSocketMouseDataProvider extends MouseDataProvider {
|
||||
this.#pointerClient = PointerClient.getInstance();
|
||||
this.#connected = false;
|
||||
try {
|
||||
this.#pointerClient.start(this.mkbHandler);
|
||||
this.#pointerClient.start(STATES.pointerServerPort, this.mkbHandler);
|
||||
this.#connected = true;
|
||||
} catch (e) {
|
||||
Toast.show('Cannot enable Mouse & Keyboard feature');
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Toast } from "@/utils/toast";
|
||||
import { PointerClient } from "./pointer-client";
|
||||
import { AppInterface } from "@/utils/global";
|
||||
import { AppInterface, STATES } from "@/utils/global";
|
||||
import { MkbHandler } from "./base-mkb-handler";
|
||||
import { t } from "@/utils/translation";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
@ -149,7 +149,7 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
this.#updateInputConfigurationAsync(false);
|
||||
|
||||
try {
|
||||
this.#pointerClient.start(this);
|
||||
this.#pointerClient.start(STATES.pointerServerPort, this);
|
||||
} catch (e) {
|
||||
Toast.show('Cannot enable Mouse & Keyboard feature');
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ enum PointerAction {
|
||||
|
||||
|
||||
export class PointerClient {
|
||||
static #PORT = 9269;
|
||||
|
||||
private static instance: PointerClient;
|
||||
public static getInstance(): PointerClient {
|
||||
if (!PointerClient.instance) {
|
||||
@ -28,11 +26,15 @@ export class PointerClient {
|
||||
#socket: WebSocket | undefined | null;
|
||||
#mkbHandler: MkbHandler | undefined;
|
||||
|
||||
start(mkbHandler: MkbHandler) {
|
||||
start(port: number, mkbHandler: MkbHandler) {
|
||||
if (!port) {
|
||||
throw new Error('PointerServer port is 0');
|
||||
}
|
||||
|
||||
this.#mkbHandler = mkbHandler;
|
||||
|
||||
// Create WebSocket connection.
|
||||
this.#socket = new WebSocket(`ws://localhost:${PointerClient.#PORT}`);
|
||||
this.#socket = new WebSocket(`ws://localhost:${port}`);
|
||||
this.#socket.binaryType = 'arraybuffer';
|
||||
|
||||
// Connection opened
|
||||
|
2
src/types/index.d.ts
vendored
2
src/types/index.d.ts
vendored
@ -51,6 +51,8 @@ type BxStates = {
|
||||
serverId: string;
|
||||
};
|
||||
}>;
|
||||
|
||||
pointerServerPort: number;
|
||||
}
|
||||
|
||||
type DualEnum = {[index: string]: number} & {[index: number]: string};
|
||||
|
@ -22,4 +22,6 @@ export const STATES: BxStates = {
|
||||
|
||||
currentStream: {},
|
||||
remotePlay: {},
|
||||
|
||||
pointerServerPort: 9269,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user