diff --git a/tools/test_websocket.html b/tools/test_websocket.html index e62bde2d..0aafb60e 100644 --- a/tools/test_websocket.html +++ b/tools/test_websocket.html @@ -140,8 +140,17 @@
+ + : + + + +
+ +
+
@@ -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 = ``; + + log('collisionLog', `服务器地址已更新为: ${serverUrl}`, 'info'); + } + // 消息统计 let messageStats = { total: 0, @@ -606,6 +633,8 @@ // 页面加载完成 window.onload = function() { + // 初始化服务器地址 + updateServerAddress(); log('collisionLog', '冲突检测WebSocket测试就绪', 'info'); };