-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
36 lines (33 loc) · 1.1 KB
/
index.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
30
31
32
33
34
35
36
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
if (window.WebSocket === undefined) {
$("#container").append("Your browser does not support WebSockets");
return;
} else {
initWS();
}
function initWS() {
var socket = new WebSocket("ws://localhost:8089/ws"),
container = $("#container")
socket.onopen = function() {
container.append("<p>Socket is open</p>");
};
socket.onmessage = function (e) {
container.append("<p> From Server :" + e.data + "</p>");
}
socket.onclose = function () {
container.append("<p>Socket closed</p>");
}
return socket;
}
});
</script>
</body>
</html>