@sususgh/gamer-dsh-plugin 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -18
- package/desktop-runtime/server.js +51 -2
- package/docs/DSH-INSTALL.zh-CN.md +6 -13
- package/dsh/client.js +18 -10
- package/package.json +5 -3
- package/start-linux.sh +18 -0
- package/start-windows.bat +30 -0
package/README.md
CHANGED
|
@@ -19,24 +19,51 @@ The phone is not expected to host a large language model. It can perform lightwe
|
|
|
19
19
|
- **Desktop role:** main processing, local game control, model routing, device bridge and telemetry
|
|
20
20
|
- **Android role:** mobile game runtime, screen/audio/sensor observations when permitted, touch execution and acknowledgements
|
|
21
21
|
|
|
22
|
-
>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
> **项目状态 / Project status:** DSH 插件页通过本机回环地址连接 Gamer 桌面配对服务。默认端口为 `8765`,可在启动脚本中自定义;插件页的“桌面服务端口”必须填写相同端口。二维码令牌有效 5 分钟。配对认证、屏幕采集、触控和游戏推理能力请以各模块实际状态为准,不会将未接入功能标记为已完成。
|
|
23
|
+
>
|
|
24
|
+
> The DSH plugin connects to the local Gamer desktop pairing service. The default port is `8765`; choose a custom port in the startup script and enter the same value in the plugin's Desktop port field. QR tokens expire after five minutes. Capabilities are reported only when their runtime adapters are implemented and tested.
|
|
25
|
+
>
|
|
26
|
+
> ---
|
|
27
|
+
>
|
|
28
|
+
> ## 启动电脑端配对服务 / Start the desktop pairing service
|
|
29
|
+
>
|
|
30
|
+
> 要求 / Requirements: Node.js 22.13 or newer.
|
|
31
|
+
>
|
|
32
|
+
> **Windows:** 双击仓库根目录的 `start-windows.bat`,按提示输入端口(直接回车使用 8765)。脚本会自动安装桌面运行时依赖并启动服务。
|
|
33
|
+
>
|
|
34
|
+
> **Linux / Debian / Ubuntu:**
|
|
35
|
+
>
|
|
36
|
+
> ```bash
|
|
37
|
+
> bash start-linux.sh
|
|
38
|
+
> ```
|
|
39
|
+
>
|
|
40
|
+
> 按提示输入端口(默认 8765)。脚本会自动安装依赖并启动服务。
|
|
41
|
+
>
|
|
42
|
+
> **手动启动 / Manual start:**
|
|
43
|
+
>
|
|
44
|
+
> ```bash
|
|
45
|
+
> cd desktop-runtime
|
|
46
|
+
> npm install
|
|
47
|
+
> ```
|
|
48
|
+
>
|
|
49
|
+
> Windows PowerShell:
|
|
50
|
+
>
|
|
51
|
+
> ```powershell
|
|
52
|
+
> $env:GAMER_PORT = "8765"
|
|
53
|
+
> npm start
|
|
54
|
+
> ```
|
|
55
|
+
>
|
|
56
|
+
> Linux:
|
|
57
|
+
>
|
|
58
|
+
> ```bash
|
|
59
|
+
> GAMER_PORT=8765 npm start
|
|
60
|
+
> ```
|
|
61
|
+
>
|
|
62
|
+
> 将 `8765` 替换为 1–65535 范围内未被占用的端口。启动后保持终端窗口运行。打开 DSH 插件页,在“桌面服务端口 / Desktop port”填写相同端口并点击“应用端口并重连”。电脑和手机需处于同一可信任局域网。
|
|
63
|
+
>
|
|
64
|
+
> 若页面显示 `Failed to fetch`,请依次检查:① 启动脚本窗口是否仍在运行;② 插件页端口与启动端口是否一致;③ 端口是否被其他程序占用或被防火墙拦截;④ DSH 是否允许本地网络访问。不要直接双击 `desktop-ui/index.html`,必须由桌面服务提供页面。不要将此 HTTP 服务或端口映射到公网。
|
|
65
|
+
>
|
|
66
|
+
> ## DSH model registry integration
|
|
40
67
|
|
|
41
68
|
The plugin now injects the Harness `llm` service and registers the model-callable tool `gamer_list_ai_models`. When invoked by the active DSH model, it reads currently registered provider routes with `ctx.llm.listProviders()` and each provider's advertised models with `ctx.llm.listModels(provider)`. It returns provider/model identifiers and availability only; it never returns API keys or secret values.
|
|
42
69
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
3
|
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { readFile } from 'node:fs/promises';
|
|
@@ -9,7 +10,12 @@ import { PairingManager } from './pairing.js';
|
|
|
9
10
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
10
11
|
const UI_ROOT = path.join(ROOT, 'desktop-ui');
|
|
11
12
|
const PORT = Number.parseInt(process.env.GAMER_PORT || '8765', 10);
|
|
13
|
+
if (!Number.isInteger(PORT) || PORT < 1 || PORT > 65535) {
|
|
14
|
+
console.error('[gamer-desktop] Invalid GAMER_PORT. Use an integer from 1 to 65535.');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
12
17
|
const manager = new PairingManager();
|
|
18
|
+
const pairedSessions = new Map();
|
|
13
19
|
const MIME = {
|
|
14
20
|
'.html': 'text/html; charset=utf-8',
|
|
15
21
|
'.js': 'text/javascript; charset=utf-8',
|
|
@@ -162,18 +168,61 @@ async function handle(req, res) {
|
|
|
162
168
|
});
|
|
163
169
|
}
|
|
164
170
|
|
|
171
|
+
if (url.pathname === '/api/pairing/claim' && req.method === 'POST') {
|
|
172
|
+
let body;
|
|
173
|
+
try { body = await readJson(req); }
|
|
174
|
+
catch (error) { return sendJson(res, 400, { error: error.message }); }
|
|
175
|
+
if (body.protocol !== 'gamer-runtime/1' || body.instance_id !== manager.instanceId
|
|
176
|
+
|| typeof body.device_id !== 'string' || body.device_id.length < 8 || body.device_id.length > 128
|
|
177
|
+
|| typeof body.device_name !== 'string' || body.device_name.length > 120) {
|
|
178
|
+
return sendJson(res, 400, { error: 'INVALID_PAIRING_REQUEST' });
|
|
179
|
+
}
|
|
180
|
+
if (!manager.verify(body.token, { consume: true })) {
|
|
181
|
+
return sendJson(res, 410, { error: 'PAIRING_TOKEN_INVALID_EXPIRED_OR_USED' });
|
|
182
|
+
}
|
|
183
|
+
const sessionId = randomBytes(18).toString('base64url');
|
|
184
|
+
const sessionToken = randomBytes(32).toString('base64url');
|
|
185
|
+
pairedSessions.set(sessionId, {
|
|
186
|
+
tokenHash: createHash('sha256').update(sessionToken).digest('hex'),
|
|
187
|
+
deviceId: body.device_id,
|
|
188
|
+
deviceName: body.device_name,
|
|
189
|
+
createdAt: Date.now(),
|
|
190
|
+
lastSeenAt: Date.now(),
|
|
191
|
+
});
|
|
192
|
+
return sendJson(res, 200, {
|
|
193
|
+
paired: true,
|
|
194
|
+
protocol: 'gamer-runtime/1',
|
|
195
|
+
instanceId: manager.instanceId,
|
|
196
|
+
sessionId,
|
|
197
|
+
sessionToken,
|
|
198
|
+
device: { id: body.device_id, name: body.device_name },
|
|
199
|
+
capabilities: { pairing: true, heartbeat: true, screenCapture: false, inputControl: false, modelInference: false },
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (url.pathname === '/api/pairing/heartbeat' && req.method === 'POST') {
|
|
204
|
+
const auth = req.headers.authorization || '';
|
|
205
|
+
const token = auth.startsWith('Bearer ') ? auth.slice(7) : '';
|
|
206
|
+
const hash = createHash('sha256').update(token).digest('hex');
|
|
207
|
+
const entry = [...pairedSessions.entries()].find(([, value]) => value.tokenHash === hash);
|
|
208
|
+
if (!entry) return sendJson(res, 401, { error: 'SESSION_UNAUTHORIZED' });
|
|
209
|
+
entry[1].lastSeenAt = Date.now();
|
|
210
|
+
return sendJson(res, 200, { connected: true, sessionId: entry[0], serverTime: Date.now() });
|
|
211
|
+
}
|
|
212
|
+
|
|
165
213
|
if (url.pathname === '/api/pairing/stop' && req.method === 'POST') {
|
|
166
214
|
if (!isLoopback(req.socket.remoteAddress)) {
|
|
167
215
|
return sendJson(res, 403, { error: 'PAIRING_CONTROL_LOCAL_ONLY' });
|
|
168
216
|
}
|
|
169
217
|
manager.stop();
|
|
170
|
-
|
|
218
|
+
pairedSessions.clear();
|
|
219
|
+
return sendJson(res, 200, { active: false, sessionsRevoked: true });
|
|
171
220
|
}
|
|
172
221
|
|
|
173
222
|
if (url.pathname === '/pair' && req.method === 'GET') {
|
|
174
223
|
const valid = url.searchParams.get('protocol') === 'gamer-runtime/1'
|
|
175
224
|
&& url.searchParams.get('instance_id') === manager.instanceId
|
|
176
|
-
&& manager.verify(url.searchParams.get('token')
|
|
225
|
+
&& manager.verify(url.searchParams.get('token'));
|
|
177
226
|
res.writeHead(valid ? 200 : 410, {
|
|
178
227
|
'content-type': 'text/html; charset=utf-8',
|
|
179
228
|
'cache-control': 'no-store',
|
|
@@ -19,26 +19,19 @@ Gamer 是 DSH 原生插件包,不是独立的 Windows EXE,也不是直接从
|
|
|
19
19
|
|
|
20
20
|
要求:Node.js 22.13 或更高版本。电脑和手机需要连接同一个可信任的局域网。
|
|
21
21
|
|
|
22
|
-
**Windows
|
|
22
|
+
**Windows:** 克隆仓库后,双击根目录 `start-windows.bat`,按提示输入端口(默认 8765)。
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
git clone https://github.com/sususgh/Gamer-DSH-Plugin.git
|
|
26
|
-
cd Gamer-DSH-Plugin\desktop-runtime
|
|
27
|
-
npm install
|
|
28
|
-
npm start
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**Linux(Debian / Ubuntu 等):**
|
|
24
|
+
**Linux(Debian / Ubuntu):**
|
|
32
25
|
|
|
33
26
|
```bash
|
|
34
27
|
git clone https://github.com/sususgh/Gamer-DSH-Plugin.git
|
|
35
|
-
cd Gamer-DSH-Plugin
|
|
36
|
-
|
|
37
|
-
npm start
|
|
28
|
+
cd Gamer-DSH-Plugin
|
|
29
|
+
bash start-linux.sh
|
|
38
30
|
```
|
|
39
31
|
|
|
40
|
-
|
|
32
|
+
也可以手动启动:进入 `desktop-runtime`,执行 `npm install`,然后设置环境变量 `GAMER_PORT=8765` 并运行 `npm start`。端口可改为 1–65535 之间未被占用的端口。
|
|
41
33
|
|
|
34
|
+
打开 DSH 插件页,在“桌面服务端口 / Desktop port”填写与启动脚本相同的端口,点击“应用端口并重连”。电脑与手机需处于同一可信任局域网。若出现 `Failed to fetch`,检查启动窗口、端口一致性、本机防火墙和 DSH 本地网络权限。Windows 防火墙只允许在可信的专用网络中访问。
|
|
42
35
|
手机相机扫码后会打开电脑的配对验证页。当前阶段实现的是**电脑端真实二维码生成与扫码落地页验证**;Android Companion 尚未实现设备身份提交、双端认证和会话握手,因此扫码成功不代表设备已连接,也不能开始游戏控制。不要将该 HTTP 服务或端口映射到公网。
|
|
43
36
|
|
|
44
37
|
## 当前功能状态
|
package/dsh/client.js
CHANGED
|
@@ -7,7 +7,7 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
|
|
8
8
|
const COPY = {
|
|
9
9
|
zh: {
|
|
10
|
-
title: 'Gamer 游戏智能体', subtitle: 'PC 游戏控制中心 · Android 手机伴侣', version: '版本 1.0.
|
|
10
|
+
title: 'Gamer 游戏智能体', subtitle: 'PC 游戏控制中心 · Android 手机伴侣', version: '版本 1.0.5',
|
|
11
11
|
overview: '运行状态', ready: 'DSH 插件入口已加载',
|
|
12
12
|
desktop: '桌面端控制台', desktopValue: '界面框架已提供,游戏运行时尚未接入',
|
|
13
13
|
android: 'Android 手机伴侣', androidValue: '通信服务尚未接入',
|
|
@@ -23,7 +23,7 @@ window.__ModuleLoader__.load({
|
|
|
23
23
|
status: '未连接', noGameControl: '当前版本不会控制游戏或发送键鼠/触控指令。'
|
|
24
24
|
},
|
|
25
25
|
en: {
|
|
26
|
-
title: 'Gamer AI Agent', subtitle: 'PC game control center · Android companion', version: 'Version 1.0.
|
|
26
|
+
title: 'Gamer AI Agent', subtitle: 'PC game control center · Android companion', version: 'Version 1.0.5',
|
|
27
27
|
overview: 'Runtime status', ready: 'Native DSH plugin entry loaded',
|
|
28
28
|
desktop: 'Desktop control center', desktopValue: 'UI shell is present; game runtime is not connected',
|
|
29
29
|
android: 'Android companion', androidValue: 'Communication service is not connected',
|
|
@@ -31,7 +31,7 @@ window.__ModuleLoader__.load({
|
|
|
31
31
|
automation: 'Automatic gameplay', automationValue: 'Not implemented; no game actions are executed',
|
|
32
32
|
pairing: 'QR device pairing', pairingHint: 'Pair an Android phone securely after the companion service is available.',
|
|
33
33
|
qrUnavailable: 'QR pairing service is not connected',
|
|
34
|
-
qrDetail: '
|
|
34
|
+
qrDetail: 'The desktop pairing service must be running locally. Set the same custom port here and in the startup script to generate a real QR code.',
|
|
35
35
|
qrNote: 'No fake QR code is shown and no device is reported as connected.',
|
|
36
36
|
roadmap: 'Next steps', roadmapText: 'Implement the desktop pairing service and Android companion before enabling QR generation, two-sided authentication and device status sync.',
|
|
37
37
|
repo: 'View GitHub project and development progress', language: 'Language', chinese: '简体中文', english: 'English',
|
|
@@ -60,8 +60,10 @@ window.__ModuleLoader__.load({
|
|
|
60
60
|
const [error, setError] = React.useState('');
|
|
61
61
|
const [busy, setBusy] = React.useState(false);
|
|
62
62
|
const [addresses, setAddresses] = React.useState([]);
|
|
63
|
+
const [port, setPort] = React.useState(() => { try { return localStorage.getItem('gamer.desktop.port') || '8765'; } catch { return '8765'; } });
|
|
63
64
|
const c = COPY[language];
|
|
64
|
-
const
|
|
65
|
+
const validPort = /^([1-9][0-9]{0,4})$/.test(port) && Number(port) <= 65535;
|
|
66
|
+
const base = 'http://127.0.0.1:' + (validPort ? port : '8765');
|
|
65
67
|
|
|
66
68
|
const generateQr = React.useCallback(async (selectedHost) => {
|
|
67
69
|
if (!selectedHost) return;
|
|
@@ -82,7 +84,7 @@ window.__ModuleLoader__.load({
|
|
|
82
84
|
} catch (e) {
|
|
83
85
|
setQr(''); setPairState('二维码生成失败'); setError(e.message || String(e));
|
|
84
86
|
} finally { setBusy(false); }
|
|
85
|
-
}, []);
|
|
87
|
+
}, [base]);
|
|
86
88
|
|
|
87
89
|
const detectAndGenerate = React.useCallback(async () => {
|
|
88
90
|
setBusy(true); setError(''); setPairState('正在检测桌面配对服务…');
|
|
@@ -97,10 +99,10 @@ window.__ModuleLoader__.load({
|
|
|
97
99
|
await generateQr(selected);
|
|
98
100
|
} catch (e) {
|
|
99
101
|
setQr(''); setPairState('桌面配对服务不可用');
|
|
100
|
-
setError((e.message || String(e)) + '。请先在电脑运行 Gamer
|
|
102
|
+
setError((e.message || String(e)) + '。请先在电脑运行 Gamer 桌面端启动脚本,并确认本机端口 ' + port + ' 可用;如修改端口,请确保启动脚本与此处填写一致。');
|
|
101
103
|
setBusy(false);
|
|
102
104
|
}
|
|
103
|
-
}, [generateQr]);
|
|
105
|
+
}, [generateQr, base]);
|
|
104
106
|
|
|
105
107
|
React.useEffect(() => {
|
|
106
108
|
let alive = true;
|
|
@@ -150,8 +152,14 @@ window.__ModuleLoader__.load({
|
|
|
150
152
|
h('section', { style: { display: 'grid', gridTemplateColumns: 'minmax(0,1fr) minmax(180px,220px)', gap: '18px', alignItems: 'center', padding: '16px', borderRadius: '14px', border: '1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))' } },
|
|
151
153
|
h('div', { style: { minWidth: 0 } },
|
|
152
154
|
h('div', { style: { fontSize: '15px', fontWeight: 700 } }, c.pairing),
|
|
153
|
-
h('p', { style: { fontSize: '12px', lineHeight: 1.65, color: 'var(--dsw-alias-label-secondary, #777)' } }, '页面加载后会自动连接本机 Gamer
|
|
154
|
-
h('div', { style: {
|
|
155
|
+
h('p', { style: { fontSize: '12px', lineHeight: 1.65, color: 'var(--dsw-alias-label-secondary, #777)' } }, '页面加载后会自动连接本机 Gamer 桌面服务并生成真实二维码。电脑与手机需要处于同一局域网。可自定义桌面服务端口,并与启动脚本中的端口保持一致。'),
|
|
156
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', margin: '10px 0' } },
|
|
157
|
+
h('label', { htmlFor: 'gamer-local-port', style: { fontSize: '12px' } }, '桌面服务端口 / Desktop port'),
|
|
158
|
+
h('input', { id: 'gamer-local-port', type: 'number', min: 1, max: 65535, step: 1, value: port, onChange: e => setPort(e.target.value), onBlur: () => { try { localStorage.setItem('gamer.desktop.port', port); } catch {} }, style: { width: '92px', padding: '7px 9px', borderRadius: '8px', border: '1px solid var(--dsw-alias-border-l2, #aaa)', background: 'var(--dsw-alias-bg-layer-1, transparent)', color: 'inherit' } }),
|
|
159
|
+
h('button', { type: 'button', disabled: busy || !validPort, onClick: () => { try { localStorage.setItem('gamer.desktop.port', port); } catch {} detectAndGenerate(); }, style: { borderRadius: '8px', padding: '7px 10px' } }, '应用端口并重连')
|
|
160
|
+
),
|
|
161
|
+
!validPort ? h('p', { role: 'alert', style: { color: '#c45b50', fontSize: '12px' } }, '端口必须是 1–65535 的整数。') : null,
|
|
162
|
+
h('div', { style: { fontSize: '13px', fontWeight: 650 } }, pairState),
|
|
155
163
|
host ? h('p', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #777)' } }, '电脑地址:' + host) : null,
|
|
156
164
|
h('p', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #777)' } }, qr ? ('有效期:' + Math.floor(remaining / 60) + ':' + String(remaining % 60).padStart(2, '0')) : '有效期:未生成'),
|
|
157
165
|
error ? h('p', { role: 'alert', style: { color: '#c45b50', fontSize: '12px', lineHeight: 1.6 } }, error) : null,
|
|
@@ -173,7 +181,7 @@ window.__ModuleLoader__.load({
|
|
|
173
181
|
),
|
|
174
182
|
h('section', { style: { padding: '14px', borderRadius: '12px', background: 'var(--dsw-alias-bg-layer-2, rgba(127,127,127,.06))' } },
|
|
175
183
|
h('div', { style: { fontSize: '13px', fontWeight: 700, marginBottom: '5px' } }, c.overview),
|
|
176
|
-
h('div', { style: { fontSize: '12px', lineHeight: 1.65, color: 'var(--dsw-alias-label-secondary, #777)' } }, 'DSH
|
|
184
|
+
h('div', { style: { fontSize: '12px', lineHeight: 1.65, color: 'var(--dsw-alias-label-secondary, #777)' } }, 'DSH 插件界面与桌面配对服务通过本机回环地址通信。若服务未启动,请先运行桌面端启动脚本。端口可在上方自定义;若仍出现 Failed to fetch,请检查服务是否运行、端口是否一致以及 DSH 是否允许本地网络访问。游戏控制、视觉识别和 Android 双端认证仍需各自运行时实现。')
|
|
177
185
|
),
|
|
178
186
|
h('a', { href: 'https://github.com/sususgh/Gamer-DSH-Plugin', target: '_blank', rel: 'noreferrer',
|
|
179
187
|
style: { fontSize: '12px', color: 'var(--dsw-alias-label-link, #4b91d1)', textDecoration: 'none' } }, c.repo + ' ↗')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sususgh/gamer-dsh-plugin",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Gamer 游戏智能体:PC 控制中心 + Android 手机伴侣。启动:Windows 双击 start-windows.bat;Linux 执行 bash start-linux.sh。端口可自定义。 | Gamer AI agent for PC + Android. Start: Windows start-windows.bat; Linux bash start-linux.sh. Custom port supported.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "sususgh",
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
"LICENSE",
|
|
30
30
|
"docs/DSH-INSTALL.zh-CN.md",
|
|
31
31
|
"docs/runtime-protocol-v1.md",
|
|
32
|
-
"locale"
|
|
32
|
+
"locale",
|
|
33
|
+
"start-windows.bat",
|
|
34
|
+
"start-linux.sh"
|
|
33
35
|
],
|
|
34
36
|
"exports": {
|
|
35
37
|
".": "./dsh/index.js",
|
package/start-linux.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
DEFAULT_PORT=8765
|
|
4
|
+
read -r -p "Gamer desktop port [${DEFAULT_PORT}]: " GAMER_PORT
|
|
5
|
+
GAMER_PORT="${GAMER_PORT:-$DEFAULT_PORT}"
|
|
6
|
+
if ! [[ "$GAMER_PORT" =~ ^[0-9]+$ ]] || (( GAMER_PORT < 1 || GAMER_PORT > 65535 )); then
|
|
7
|
+
echo "Invalid port. Enter an integer from 1 to 65535."
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
cd "$(dirname "$0")/desktop-runtime"
|
|
11
|
+
if [[ ! -d node_modules/qrcode ]]; then
|
|
12
|
+
echo "Installing desktop runtime dependencies..."
|
|
13
|
+
npm install
|
|
14
|
+
fi
|
|
15
|
+
export GAMER_PORT
|
|
16
|
+
echo "Starting Gamer desktop service on port $GAMER_PORT..."
|
|
17
|
+
echo "Keep this terminal open while using the DSH plugin."
|
|
18
|
+
npm start
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
title Gamer Desktop Pairing Service
|
|
4
|
+
echo ==========================================
|
|
5
|
+
echo Gamer Desktop - QR Pairing Service
|
|
6
|
+
echo ==========================================
|
|
7
|
+
set "GAMER_PORT=8765"
|
|
8
|
+
set /p "GAMER_PORT=Enter port (1-65535) [8765]: "
|
|
9
|
+
if "%GAMER_PORT%"=="" set "GAMER_PORT=8765"
|
|
10
|
+
powershell -NoProfile -Command "if ([int]::TryParse('%GAMER_PORT%', [ref]$p) -and $p -ge 1 -and $p -le 65535) { exit 0 } else { exit 1 }"
|
|
11
|
+
if errorlevel 1 (
|
|
12
|
+
echo Invalid port. Please enter a number from 1 to 65535.
|
|
13
|
+
pause
|
|
14
|
+
exit /b 1
|
|
15
|
+
)
|
|
16
|
+
cd /d "%~dp0desktop-runtime"
|
|
17
|
+
if not exist "node_modules\qrcode" (
|
|
18
|
+
echo Installing desktop runtime dependencies...
|
|
19
|
+
call npm install
|
|
20
|
+
if errorlevel 1 (
|
|
21
|
+
echo Dependency installation failed.
|
|
22
|
+
pause
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
set "GAMER_PORT=%GAMER_PORT%"
|
|
27
|
+
echo Starting Gamer on port %GAMER_PORT%...
|
|
28
|
+
echo Keep this window open while using the DSH plugin.
|
|
29
|
+
call npm start
|
|
30
|
+
pause
|