설명 메시지 브릿지 테스트 샘플 소스
페이지 정보
본문
여러분의 사이트에서도 즉시 테스트해 보세요.
아래 제공된 메시지 브릿지 테스트용 샘플 소스를 복사하여, 귀하의 서버 또는 로컬 환경에 새로운 테스트 파일을 생성한 뒤 그대로 붙여 넣고 저장해 보시기 바랍니다.
또는, simpleTest.html 파일을 다운로드 받으셔도 됩니다.
파일을 실행하는 즉시,
귀하의 사이트 환경에서 메시지 브릿지가 정상적으로 동작하는지 실시간으로 확인하실 수 있습니다.
메시지 브릿지는 개발 언어, 서버 환경, 플랫폼에 관계없이 연동 가능합니다.
별도의 설치 과정 없이, 제공된 샘플만으로도 서비스 동작 여부와 통신 흐름을 직접 검증하실 수 있습니다.
지금 바로 적용해 보시고,
여러분의 서비스에 실시간 메시징 기능이 얼마나 손쉽게 통합되는지 확인해 보세요.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>메시지 브릿지 Simple Test</title>
<style>
body { font-family: Arial; padding: 20px; }
#log { width: 100%; height: 250px; overflow-y: auto; border: 1px solid #aaa; padding: 10px; }
#msg { width: 70%; }
button { width: 25%; }
</style>
</head>
<body>
<h3>메시지 브릿지 Minimal Test</h3>
<input id="msg" type="text" placeholder="메시지를 입력하세요">
<button id="sendBtn">Send</button>
<pre id="log"></pre>
<script>
// ---------------------------
// 기본 설정
// ---------------------------
const group = window.location.hostname; // 예: designonex.com
const myId = "user_" + Math.floor(Math.random() * 9999); // 랜덤 사용자 ID
// 확장 필드 (개발자가 관리)
const extValue = "ext_example";
const extValue1 = "ext1_example";
// ---------------------------
// WebSocket 연결
// ---------------------------
const ws = new WebSocket(
"wss://designonex.com:14147/?group=" + encodeURIComponent(group)
);
// ---------------------------
// 로그 출력 함수
// ---------------------------
function log(msg) {
const box = document.getElementById("log");
box.textContent += msg + "\n";
box.scrollTop = box.scrollHeight;
}
// ---------------------------
// WebSocket 이벤트
// ---------------------------
ws.onopen = () => log("Connected");
ws.onmessage = (event) => {
try {
const data = JSON.parse(event.data);
log("Received: " + JSON.stringify(data));
} catch {
log("Received(Text): " + event.data);
}
};
ws.onclose = () => log("Connection Closed");
ws.onerror = (e) => log("Error: " + e);
// ---------------------------
// 메시지 전송
// ---------------------------
document.getElementById("sendBtn").onclick = () => {
const msg = document.getElementById("msg").value;
if (!msg) return;
const data = {
type: "message",
id: myId,
ext: extValue,
ext1: extValue1,
message: msg
};
ws.send(JSON.stringify(data));
log("Sent: " + JSON.stringify(data));
document.getElementById("msg").value = "";
};
</script>
</body>
</html>
추천0 비추천0
첨부파일
-
simpleTest.html (2.2K)
1회 다운로드 | DATE : 2025-11-10 23:58:21
관련링크
댓글목록
등록된 댓글이 없습니다.
