rf-web/vendor/bundle/gems/em-websocket-0.5.1/examples/test.html
2019-10-21 10:18:17 +02:00

30 lines
927 B
HTML

<html>
<head>
<script>
function init() {
function debug(string) {
var element = document.getElementById("debug");
var p = document.createElement("p");
p.appendChild(document.createTextNode(string));
element.appendChild(p);
}
var Socket = "MozWebSocket" in window ? MozWebSocket : WebSocket;
var ws = new Socket("ws://localhost:8080/foo/bar?hello=world");
ws.onmessage = function(evt) { debug("Received: " + evt.data); };
ws.onclose = function(event) {
debug("Closed - code: " + event.code + ", reason: " + event.reason + ", wasClean: " + event.wasClean);
};
ws.onopen = function() {
debug("connected...");
ws.send("hello server");
ws.send("hello again");
};
};
</script>
</head>
<body onload="init();">
<div id="debug"></div>
</body>
</html>