surrealpatch/tpl/index.html

36 lines
805 B
HTML
Raw Normal View History

2016-02-27 12:05:10 +00:00
<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket</title>
<script>
2016-04-03 23:12:35 +00:00
var uri = "ws://127.0.0.1:8000/rpc";
2016-02-27 12:05:10 +00:00
function init() {
websocket = new WebSocket(uri);
websocket.onopen = function(evt) {
document.getElementById('output').innerHTML = '<span style="color:#00CC00;">Connected</span>';
};
websocket.onclose = function(evt) {
document.getElementById('output').innerHTML = '<span style="color:#FF0000;">Disconnected</span>';
};
websocket.onmessage = function(evt) {
console.log(evt.data)
};
websocket.onerror = function(evt) {
console.warn(evt.data)
};
}
window.addEventListener("load", init, false);
</script>
<h2>WebSocket</h2>
<div id="output"></div>