-
Notifications
You must be signed in to change notification settings - Fork 50
/
simpleclient.html
44 lines (33 loc) · 959 Bytes
/
simpleclient.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
37
38
39
40
41
42
43
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>websocket</title>
<style type="text/css">
</style>
</head>
<body>
<div id="connected"></div>
<script type="text/javascript">
var onOpen = function() {
console.log("Socket opened.");
socket.send("Hi, Server!");
},
onClose = function() {
console.log("Socket closed.");
},
onMessage = function(data) {
console.log("We get signal:");
console.log(data);
},
onError = function() {
console.log("We got an error.");
},
socket = new WebSocket("ws://127.0.0.1:8080/");
socket.onopen = onOpen;
socket.onclose = onClose;
socket.onerror = onError;
socket.onmessage = onMessage;
</script>
</body>
</html>