forked from josephj/sync-with-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-socket.html
More file actions
55 lines (44 loc) · 1.21 KB
/
web-socket.html
File metadata and controls
55 lines (44 loc) · 1.21 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web Socket</title>
<style>
#show {
border: solid 1px #ccc;
padding: 5px;
width: 500px;
height: 500px;
font-size: 11px;
overflow: auto;
}
</style>
</head>
<body>
<h1>Web Socket (Full Deplux)</h1>
<div id="show"></div>
<script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
<script type="text/javascript">
YUI().use("node-base", function (Y) {
var node = Y.one("#show");
var conn = new WebSocket("ws://172.17.66.2:1388/test");
conn.onopen = function (e) {
Y.log("WebSocket instance is ready", "info");
Y.later(3000, null, function () {
conn.send("Browser said " + parseInt(new Date().getTime()) + ".");
}, null, true);
};
conn.onerror = function (e) {
Y.log("WebSocket instance has error", "info");
}
conn.onclose = function () {
Y.log("WebSocket instance is closed", "info");
}
conn.onmessage = function (e) {
Y.log(e.data);
node.append("<p>" + e.data + "</p>");
};
});
</script>
</body>
</html>