Created
March 13, 2018 22:42
-
-
Save rogerwelin/6b09cfa5c485428a4be0b36ed8da4c4c to your computer and use it in GitHub Desktop.
websocket html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<h1>Long/lat:</h1> | |
<!-- 1 --> | |
<div id="long"></div> | |
<div id="lat"></div> | |
<script type="text/javascript"> | |
var long = document.getElementById("long"); | |
var lat = document.getElementById("lat"); | |
// 2 | |
var exampleSocket = new WebSocket("ws://localhost:8844/ws") | |
// 3 | |
var update = function(){ | |
exampleSocket.onmessage = function (event) { | |
var longlatArr = event.data.split(" "); | |
long.textContent = longlatArr[1].toString(); | |
lat.textContent = longlatArr[0].toString(); | |
} | |
}; | |
window.setTimeout(update); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment