-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsocket-test.html
More file actions
106 lines (90 loc) Β· 3.14 KB
/
websocket-test.html
File metadata and controls
106 lines (90 loc) Β· 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket μ°κ²° ν
μ€νΈ</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
}
.container {
background-color: #f5f5f5;
padding: 20px;
border-radius: 8px;
}
input, button {
padding: 10px;
margin: 5px;
font-size: 14px;
}
.log {
background-color: #000;
color: #0f0;
padding: 15px;
height: 300px;
overflow-y: auto;
font-family: monospace;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>π WebSocket μ°κ²° ν
μ€νΈ</h1>
<div>
<label>WebSocket URL:</label><br>
<input type="text" id="wsUrl" style="width: 500px;"
value="wss://pityingly-overwily-dawna.ngrok-free.dev/voice/stream?call_sid=test_123">
</div>
<div style="margin-top: 10px;">
<button onclick="testConnection()">μ°κ²° ν
μ€νΈ</button>
<button onclick="clearLog()">λ‘κ·Έ μ§μ°κΈ°</button>
</div>
<div id="log" class="log"></div>
</div>
<script>
let ws = null;
function log(message) {
const logDiv = document.getElementById('log');
const timestamp = new Date().toLocaleTimeString();
logDiv.innerHTML += `[${timestamp}] ${message}\n`;
logDiv.scrollTop = logDiv.scrollHeight;
}
function clearLog() {
document.getElementById('log').innerHTML = '';
}
function testConnection() {
const url = document.getElementById('wsUrl').value;
if (ws) {
ws.close();
ws = null;
}
log(`μ°κ²° μλ: ${url}`);
try {
ws = new WebSocket(url);
ws.onopen = function(event) {
log('β
WebSocket μ°κ²° μ±κ³΅!');
};
ws.onmessage = function(event) {
log(`π¨ λ©μμ§ μμ : ${event.data}`);
};
ws.onclose = function(event) {
log(`β μ°κ²° μ’
λ£: μ½λ=${event.code}, μ΄μ =${event.reason || 'μμ'}`);
};
ws.onerror = function(error) {
log(`π¨ WebSocket μ€λ₯ λ°μ`);
};
} catch (error) {
log(`π¨ μ°κ²° μ€ν¨: ${error.message}`);
}
}
// νμ΄μ§ λ‘λ μ μλ ν
μ€νΈ
log('WebSocket ν
μ€νΈ νμ΄μ§ λ‘λλ¨');
log('μ URLμ΄ μ ννμ§ νμΈνκ³ "μ°κ²° ν
μ€νΈ" λ²νΌμ λλ₯΄μΈμ');
</script>
</body>
</html>