v1.3.6: 목소리 깨짐(RTP 기준 쉼 채우기) · 알 수 없음 · 잡음 숨기기/삭제 · 사이트 로그 · 지금 게임 · TTS 속도 · 시작 창
- 녹음기: 패킷 도착 간격 대신 RTP 타임스탬프로 자리를 정한다. 게임 중 몰려 온 패킷 사이에 무음이 끼어 목소리가 깨졌다. 예전 녹음은 한 번 고친 뒤 다시 변환 - users.updated 를 빈 목록으로 보내 사이트에서 말한 사람이 '알 수 없음'이 되던 것 - 잡음은 숨기고 ogg 삭제, 로그에 잡음으로 남김. 짧은 목소리도 Whisper 로, 반복 고리는 줄여서 보여 줌 - 사이트: 재생 음량, 발화 우클릭(자세한 정보 · ogg 다운로드), 사이트 로그(/logs, 게임 PC 꺼져도), 지금 게임 상태 - 앱: 지금 게임 상태, 녹음 안내 말 속도 0.1~2.0, 포터블 · 앱 시작 창 - 발로란트 데스매치 가짜 라운드 · 에이스, 빈 선수 이름 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,9 @@ import { WebSocket, WebSocketServer } from 'ws';
|
||||
import type { BrowserMessage, DeviceStatus, LiveEvent, RelayFromDevice, RelayToDevice } from '@gvr/shared';
|
||||
import type { ServerStore } from './store.js';
|
||||
|
||||
type Log = { info: (o: any, m?: string) => void; warn: (o: any, m?: string) => void };
|
||||
const NOLOG: Log = { info: () => undefined, warn: () => undefined };
|
||||
|
||||
const OFFLINE_AFTER_MS = 15000;
|
||||
|
||||
interface Pending {
|
||||
@@ -33,6 +36,9 @@ export class RelayHub {
|
||||
private watchdog: NodeJS.Timeout;
|
||||
private lastStatus = '';
|
||||
|
||||
/** 사이트 로그 (app.ts 가 [relay] 영역 로거를 넣는다) */
|
||||
log: Log = NOLOG;
|
||||
|
||||
constructor(private store: ServerStore) {
|
||||
this.watchdog = setInterval(() => this.checkAlive(), 2000);
|
||||
}
|
||||
@@ -74,6 +80,7 @@ export class RelayHub {
|
||||
|
||||
private checkAlive(): void {
|
||||
if (this.device && Date.now() - this.device.lastMsg > OFFLINE_AFTER_MS) {
|
||||
this.log.warn({ name: this.device.name, silentMs: Date.now() - this.device.lastMsg }, '게임 PC 응답 없음 (15초) → 연결 끊음');
|
||||
this.device.ws.terminate();
|
||||
this.dropDevice(this.device.ws);
|
||||
}
|
||||
@@ -92,11 +99,13 @@ export class RelayHub {
|
||||
attachDevice(ws: WebSocket, id: string): void {
|
||||
if (this.device) {
|
||||
// 같은 기기가 다시 연결 (네트워크 재연결) → 이전 연결을 끊는다
|
||||
this.log.info({ name: this.device.name }, '게임 PC 가 다시 연결해서 이전 연결을 닫음');
|
||||
this.device.ws.close(4000, 'replaced');
|
||||
this.dropDevice(this.device.ws);
|
||||
}
|
||||
const dev = this.store.device();
|
||||
this.device = { ws, id, name: dev?.name ?? 'GAME-PC', version: null, lastMsg: Date.now() };
|
||||
this.log.info({ name: this.device.name }, '게임 PC 연결');
|
||||
this.store.touchDevice(id, { lastSeen: Date.now() });
|
||||
ws.send(JSON.stringify({ t: 'welcome', deviceId: id } satisfies RelayToDevice));
|
||||
ws.on('message', (data, isBinary) => {
|
||||
@@ -111,13 +120,14 @@ export class RelayHub {
|
||||
}
|
||||
this.onDeviceMessage(m);
|
||||
});
|
||||
ws.on('close', () => this.dropDevice(ws));
|
||||
ws.on('error', () => this.dropDevice(ws));
|
||||
ws.on('close', (code, reason) => this.dropDevice(ws, `닫힘 ${code}${reason?.length ? ' ' + String(reason) : ''}`));
|
||||
ws.on('error', (e) => this.dropDevice(ws, `오류 ${e.message}`));
|
||||
this.broadcastStatus(true);
|
||||
}
|
||||
|
||||
private dropDevice(ws: WebSocket): void {
|
||||
private dropDevice(ws: WebSocket, why = '응답 없음'): void {
|
||||
if (!this.device || this.device.ws !== ws) return;
|
||||
this.log.warn({ name: this.device.name, why, pending: this.pending.size }, '게임 PC 연결 끊김 (사이트 잠김)');
|
||||
this.store.touchDevice(this.device.id, { lastSeen: this.device.lastMsg });
|
||||
this.device = null;
|
||||
for (const [id, p] of this.pending) {
|
||||
@@ -134,6 +144,7 @@ export class RelayHub {
|
||||
case 'hello':
|
||||
dev.name = m.name;
|
||||
dev.version = m.version;
|
||||
this.log.info({ name: m.name, version: m.version, guild: m.guildId ?? null }, '게임 PC 정보');
|
||||
this.store.touchDevice(dev.id, { name: m.name, version: m.version, guildId: m.guildId ?? null, lastSeen: Date.now() });
|
||||
this.broadcastStatus(true);
|
||||
break;
|
||||
@@ -183,7 +194,10 @@ export class RelayHub {
|
||||
const id = crypto.randomBytes(8).toString('hex');
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
if (this.pending.delete(id)) reject(new Error('timeout'));
|
||||
if (this.pending.delete(id)) {
|
||||
this.log.warn({ method, path: path.split('?')[0], ms: timeoutMs }, '게임 PC 가 기록 요청에 답하지 않음 (시간 초과)');
|
||||
reject(new Error('timeout'));
|
||||
}
|
||||
}, timeoutMs);
|
||||
this.pending.set(id, { resolve, reject, timer, chunks: [] });
|
||||
const msg: RelayToDevice = { t: 'req', id, method, path, headers, user, body };
|
||||
|
||||
Reference in New Issue
Block a user