You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function WebSocketTest()
{
if("WebSocket" in window)
{
//alert("WebSocket is supported by your Browser!");
var ws= new WebSocket("ws://127.0.0.1:30318/");
ws.onopen = function()
{
var str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>7DbgT65HZFiNEQ5rK3X7eQ==</challenge></getsignandtokenreq>";
ws.send(str);
var a = document.createElement('div');
a.textContent == "" ? a.textContent= '\n开始发送请求...\n' + str : a.innerText= '\n开始发送请求...\n' + str;
document.getElementById("showResult").appendChild(a);
};
ws.onmessage = function(evt)
{
var received_msg = evt.data;
var b = document.createElement('div');
b.textContent == "" ? b.textContent = '\n返回结果\n' + evt.data:b.innerText= '\n返回结果\n' + evt.data;
document.getElementById("showResult").appendChild(b);
};
ws.onclose = function()
{
//document.write("Connection is closed...");
var c = document.createElement('div');
c.textContent == "" ? c.textContent = '\n连接已关闭' : c.innerText= '\n连接已关闭';
document.getElementById("showResult").appendChild(c);
};
}
else
{
var d = document.createElement('div');
d.textContent == "" ? d.textContent = '\n浏览器不支持websocket': d.innerText= '\n浏览器不支持websocket';
document.getElementById("showResult").appendChild(d);
}
}
</script>
</head>
<body>
<div id="sse">
<a href="javascript:WebSocketTest()">应用调用websocket标准接口测试</a>
</div>
<div id="result">
<p>测试结果:
<div id="showResult">
</div>
</div>
</body>
</html>