2020-03-15 12:41:57 +00:00
|
|
|
<!-- vim: set ts=2 sw=2 et tw=80: -->
|
|
|
|
|
2020-03-15 09:44:10 +00:00
|
|
|
<html>
|
2020-04-12 13:58:40 +00:00
|
|
|
<head>
|
2020-03-15 09:44:10 +00:00
|
|
|
<meta charset="utf-8">
|
2020-04-12 13:58:40 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="malusa">
|
|
|
|
<h1>Waiting for authentication...</h1>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
|
2020-03-15 09:44:10 +00:00
|
|
|
let malusa = document.getElementById("malusa");
|
2020-04-12 13:58:40 +00:00
|
|
|
let token = localStorage.getItem("token");
|
|
|
|
if (!token) {
|
|
|
|
token = prompt("insert authentication token");
|
|
|
|
localStorage.setItem("token", token);
|
|
|
|
}
|
|
|
|
|
|
|
|
let connection = new WebSocket("ws://localhost:8080/sensor-socket?token=" + token);
|
2020-03-15 09:44:10 +00:00
|
|
|
console.log("***CREATED WEBSOCKET");
|
|
|
|
|
2020-04-12 13:58:40 +00:00
|
|
|
let authentica
|
2020-03-15 09:44:10 +00:00
|
|
|
connection.onopen = function(evt) {
|
2020-04-12 13:58:40 +00:00
|
|
|
malusa.innerHTML = "<h1>Socket is now authenticated!</h1>" +
|
|
|
|
"<img src='https://maggioni.xyz/astley.gif'>";
|
2020-03-15 09:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
connection.onmessage = function(evt) {
|
|
|
|
console.log("***ONMESSAGE", evt);
|
|
|
|
let data = JSON.parse(evt.data);
|
|
|
|
|
2020-04-12 13:58:40 +00:00
|
|
|
malusa.innerHTML += "<p><pre>" + JSON.stringify(JSON.parse(evt.data), null, 2) + "</pre></p>";
|
2020-03-15 09:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
connection.onerror = function(evt) {
|
|
|
|
console.error("***ONERROR", evt);
|
|
|
|
};
|
2020-04-12 13:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
2020-03-15 09:44:10 +00:00
|
|
|
</html>
|