-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
39 lines (22 loc) · 802 Bytes
/
Copy pathindex.html
File metadata and controls
39 lines (22 loc) · 802 Bytes
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
<!doctype html>
<html>
<head>
<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js'></script>
</head>
<body>
<button id="fromClient">From Client</button>
<script>
var socket = io();
socket.on('fromServer', function(data) {
console.log( 'ON: fromServer');
});
socket.on('time', function(data) {
console.log( 'ON: time');
});
document.getElementById('fromClient').onclick = function(){
socket.emit('fromClient', { "message":"Sent from client!" });
console.log( 'EMIT: fromClient');
}
</script>
</body>
</html>