-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
33 lines (33 loc) · 971 Bytes
/
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
<!DOCTYPE HTML>
<html>
<head></head>
<body>
<button onclick="kirim()">Send</button>
<script>
function kirim(){
var valRand = Math.floor(Math.random() * 11);
ws.send(JSON.stringify({ //you can change this json value
"to":"jiiotclient",
"value":valRand
}));
}
var ws = new WebSocket('ws://ws.achex.ca:4010'); //achex server
var login = {setID: "youruser", passwd: "yourpassword"}; //login json
ws.onopen = function(e) {
ws.send(JSON.stringify(login)); //send login parameter
console.log(e);
console.log(JSON.stringify(login));
}
ws.onmessage = function(evt) {
var received_msg = evt.data;
console.log(received_msg);
}
ws.onclose = function(evt) {
console.log(evt);
}
ws.onerror = function(evt) {
console.log(evt);
}
</script>
</body>
</html>