Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 59271f8

Browse files
committed
Fix websocket communication
1 parent 4689a85 commit 59271f8

15 files changed

Lines changed: 54 additions & 24 deletions

File tree

.vscode/tasks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"type": "shell",
5151
"args": [
5252
"-r",
53+
"--workspace-concurrency=1",
5354
"run",
5455
"build"
5556
]

@xoutput/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"author": "Ármin Csutorás",
2929
"license": "MIT",
3030
"dependencies": {
31-
"@xoutput/api": "workspace:../api"
31+
"@xoutput/api": "workspace:*"
3232
},
3333
"devDependencies": {
3434
"@typescript-eslint/eslint-plugin": "^6.10.0",

@xoutput/client/pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

@xoutput/client/src/websocket/input/InputDeviceClient.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const inputDeviceClient = {
2626
return session;
2727
})
2828
.then(
29-
(session) =>
30-
({
31-
...session,
32-
sendInput: (input: InputDeviceInputRequest) => session.sendMessage(input),
33-
}) as WebSocketSession<InputDeviceMessageSender>
29+
(session) => {
30+
const enhancedSession = session as WebSocketSession<InputDeviceMessageSender>;
31+
enhancedSession.sendInput = (input: InputDeviceInputRequest) => session.sendMessage(input);
32+
return enhancedSession;
33+
}
3434
);
3535
},
3636
};

@xoutput/client/src/websocket/websocket.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { DebugRequest, MessageBase, PongResponse } from '@xoutput/api';
22

33
export class WebSocketService {
4-
connect(path: string, onMessage: (data: MessageBase) => void): Promise<WebSocketSessionImpl> {
4+
connect(path: string, onMessage: (data: MessageBase) => void): Promise<WSSession> {
55
return new Promise((resolve, reject) => {
6-
const url = `/websocket/${path}`;
6+
const url = `ws://${location.host}/websocket/${path}`;
77
const websocket = new WebSocket(url);
88
let session: WebSocketSessionImpl;
99
let pingInterval: number;

@xoutput/client/src/websocket/xbox/XboxDeviceClient.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export const xboxDeviceClient = {
1414
}
1515
})
1616
.then(
17-
(session) =>
18-
({
19-
...session,
20-
sendInput: (input: XboxInputRequest) => session.sendMessage(input),
21-
}) as WebSocketSession<XboxInputMessageSender>
17+
(session) => {
18+
const enhancedSession = session as WebSocketSession<XboxInputMessageSender>;
19+
enhancedSession.sendInput = (input: XboxInputRequest) => session.sendMessage(input);
20+
return enhancedSession;
21+
}
2222
);
2323
},
2424
};

@xoutput/webapp/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"private": true,
66
"scripts": {
77
"build": "tsc && vite build",
8-
"watch": "vite dev",
8+
"watch": "vite",
99
"lint": "eslint",
1010
"fix-format": "eslint --fix && prettier --write \"src/**/*.{ts,tsx}\"",
1111
"test": "echo \"No test specified\""
@@ -21,8 +21,8 @@
2121
"@mui/material": "^5.14.17",
2222
"@mui/styled-engine": "^5.14.17",
2323
"@mui/system": "^5.14.17",
24-
"@xoutput/api": "workspace:../api",
25-
"@xoutput/client": "workspace:../client",
24+
"@xoutput/api": "workspace:*",
25+
"@xoutput/client": "workspace:*",
2626
"moment": "^2.29.4",
2727
"qrcode": "^1.5.3",
2828
"react": "^18.2.0",

@xoutput/webapp/pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

@xoutput/webapp/src/gamepad/GamepadReader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class GamepadReader {
1616

1717
constructor(public gamepad: Gamepad) {}
1818

19-
start(intervalMs = 1): Promise<void> {
19+
start(intervalMs = 10): Promise<void> {
2020
if (this.intervalId) {
2121
return;
2222
}
@@ -75,9 +75,9 @@ export class GamepadReader {
7575

7676
stop(): void {
7777
if (this.intervalId) {
78-
clearInterval(this.intervalId);
7978
this.session.close();
8079
this.session = undefined;
80+
clearInterval(this.intervalId);
8181
this.intervalId = undefined;
8282
}
8383
}

@xoutput/webapp/src/ui/input/Gamepad.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const GamepadComponent = ({ gamepad }: GamepadProps) => {
2424
() => {
2525
setRunning(true);
2626
},
27-
() => {
27+
(err) => {
28+
console.error(err);
2829
/*error handling*/
2930
}
3031
);

0 commit comments

Comments
 (0)