goldenChat base source add

This commit is contained in:
aidev
2026-05-23 15:11:48 +09:00
commit a4ea7762b5
2081 changed files with 1155760 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import type { IMessage } from '@stomp/stompjs';
/** STOMP MESSAGE body — 텍스트·바이너리(UTF-8 JSON) 모두 처리 */
export function stompMessageBody(msg: IMessage): string {
if (msg.body && msg.body.length > 0) return msg.body;
const bin = msg.binaryBody;
if (bin && bin.length > 0) {
return new TextDecoder('utf-8').decode(bin);
}
return '';
}
export function parseStompJson<T>(msg: IMessage): T | null {
const raw = stompMessageBody(msg);
if (!raw) return null;
try {
return JSON.parse(raw) as T;
} catch {
return null;
}
}