Skip to content

Commit 5c74961

Browse files
committed
chore: use console to reconnect
1 parent 68ff6a5 commit 5c74961

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/lib/snapshot.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ _snapshot_upload() {
6060
local url="${STATUS_API_BASE}/game-streamer/${MATCH_ID}/snapshot"
6161
local auth="${MATCH_ID}:${MATCH_PASSWORD}"
6262

63-
# Multipart form upload — matches the FileInterceptor pattern the
64-
# other api binary uploads (branding/trophies/avatars) use.
6563
local http_code
6664
http_code=$(curl -sS -m 10 -X POST \
6765
-H "x-origin-auth: ${auth}" \
@@ -80,8 +78,8 @@ _snapshot_upload() {
8078
}
8179

8280
_snapshot_loop() {
83-
# Brief pause so cs2 has painted at least one frame before the first
84-
# snapshot — otherwise the first thumbnail is a black/loading screen.
81+
# Warm-up: cs2 needs to paint a frame before the first snapshot,
82+
# otherwise the thumbnail is a black loading screen.
8583
sleep "$SNAPSHOT_INITIAL_DELAY_SECONDS"
8684

8785
local start sleep_for
@@ -92,8 +90,6 @@ _snapshot_loop() {
9290
else
9391
warn "snapshot capture failed"
9492
fi
95-
# Subtract elapsed so cadence stays at the configured interval even
96-
# when capture+upload takes a couple of seconds.
9793
local elapsed=$(( $(date +%s) - start ))
9894
sleep_for=$(( SNAPSHOT_INTERVAL_SECONDS - elapsed ))
9995
[ "$sleep_for" -lt 1 ] && sleep_for=1

src/spectator/routes/reconnect.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import process from "node:process";
22

3-
import { execCfgCommand } from "../cs2/exec-cfg.mjs";
3+
import { sendConsoleCommand } from "../cs2/input.mjs";
44
import { findCs2Window } from "../cs2/window.mjs";
55
import { sendJson } from "../util/http.mjs";
66

@@ -65,7 +65,12 @@ export async function reconnectHandler(_req, res) {
6565
script = `disconnect; password "${target.password}"; connect ${target.addr}`;
6666
}
6767

68-
const ok = await execCfgCommand(script);
68+
// The console is layered above the "Disconnected — Unable to
69+
// establish a connection" Panorama modal, but key binds (including
70+
// the BackSpace that triggers exec_cfg) are not — the modal eats
71+
// them. So reconnect always goes through the console path, even
72+
// when EXEC_CFG_PATH is configured.
73+
const ok = await sendConsoleCommand(script);
6974
if (!ok) {
7075
sendJson(res, 503, { error: "cs2 console unreachable" });
7176
return;

0 commit comments

Comments
 (0)