-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
29 lines (28 loc) · 927 Bytes
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<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>