-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket-test.html
42 lines (33 loc) · 904 Bytes
/
socket-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
30
31
32
33
34
35
36
37
38
39
40
41
42
<!doctype html>
<html>
<head>
<title>CPP Socket Test</title>
<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script>
<script>
var ws;
function WebSocketTest() {
if ("WebSocket" in window) {
console.log("WebSocket is supported by your Browser!");
// Let us open a web socket
ws = new WebSocket("ws://localhost:5619");
ws.onopen = function() {
// Web Socket is connected, send data using send()
ws.send("Message to send");
};
ws.onmessage = function (evt) {
console.log('received data: ', evt.data);
};
ws.onclose = function() {
// websocket is closed.
alert("Connection is closed...");
};
} else {
// The browser doesn't support WebSocket
alert("WebSocket NOT supported by your Browser!");
}
}
</script>
</head>
<body>
</body>
</html>