This repository has been archived on 2023-05-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Go-PlayGround/wsnettest/test.html
2022-09-01 16:41:03 +02:00

39 lines
669 B
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WebSocket</title>
</head>
<body>
<p id="output"></p>
<script>
var loc = "localhost";
var uri = 'ws:';
if (loc.protocol === 'https:') {
uri = 'wss:';
}
uri += '//' + loc.host;
uri += loc.pathname + 'ws';
ws = new WebSocket("ws://localhost:1323")
ws.onopen = function() {
console.log('Connected')
}
ws.onmessage = function(evt) {
var out = document.getElementById('output');
out.innerHTML += evt.data + '<br>';
}
setInterval(function() {
ws.send('Hello, Server!');
}, 1000);
</script>
</body>
</html>