给 websocket 测试页面加上IP地址和端口修改
This commit is contained in:
parent
2d51887334
commit
85253e94a5
@ -140,8 +140,17 @@
|
||||
|
||||
<div class="control-group">
|
||||
<label>服务器地址:</label>
|
||||
<input type="text" id="collisionServerIP" placeholder="IP地址" value="localhost" />
|
||||
<span>:</span>
|
||||
<input type="number" id="collisionServerPort" placeholder="端口" value="8080" min="1" max="65535" />
|
||||
<input type="text" id="collisionServerPath" placeholder="路径" value="/collision" />
|
||||
<button onclick="updateServerAddress()">更新地址</button>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label>完整地址:</label>
|
||||
<select id="collisionServerSelect">
|
||||
<option value="ws://localhost:8080/collision">localhost:8080/collision</option>
|
||||
<option value="ws://localhost:8080/collision">ws://localhost:8080/collision</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -178,6 +187,24 @@
|
||||
let reconnectAttempts = 0;
|
||||
const maxReconnectAttempts = 5;
|
||||
|
||||
// 更新服务器地址
|
||||
function updateServerAddress() {
|
||||
const ip = document.getElementById('collisionServerIP').value || 'localhost';
|
||||
const port = document.getElementById('collisionServerPort').value || '8080';
|
||||
const path = document.getElementById('collisionServerPath').value || '/collision';
|
||||
|
||||
// 确保路径以 / 开头
|
||||
const formattedPath = path.startsWith('/') ? path : '/' + path;
|
||||
|
||||
const serverUrl = `ws://${ip}:${port}${formattedPath}`;
|
||||
|
||||
// 更新下拉框
|
||||
const select = document.getElementById('collisionServerSelect');
|
||||
select.innerHTML = `<option value="${serverUrl}">${serverUrl}</option>`;
|
||||
|
||||
log('collisionLog', `服务器地址已更新为: ${serverUrl}`, 'info');
|
||||
}
|
||||
|
||||
// 消息统计
|
||||
let messageStats = {
|
||||
total: 0,
|
||||
@ -606,6 +633,8 @@
|
||||
|
||||
// 页面加载完成
|
||||
window.onload = function() {
|
||||
// 初始化服务器地址
|
||||
updateServerAddress();
|
||||
log('collisionLog', '冲突检测WebSocket测试就绪', 'info');
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user