30 lines
861 B
HTML
30 lines
861 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
function wsRoute(id) {
|
|
const loc = window.location;
|
|
let newUri = loc.protocol === "https:" ? "wss://" : "ws://";
|
|
newUri += loc.host + '/ws/' + id;
|
|
return newUri;
|
|
}
|
|
|
|
// Random UUID
|
|
const ws = new WebSocket(wsRoute('7d3a9dac-71db-4ade-af46-f080777969a4'));
|
|
ws.onopen = function () {
|
|
ws.send('hello, world!');
|
|
ws.send('hello, world!');
|
|
ws.send('hello, world!');
|
|
}
|
|
ws.onmessage = function (data) {
|
|
console.log(data);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|