-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
33 lines (27 loc) · 939 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>
<meta charset="utf-8" />
<title>Socket.io</title>
</head>
<body>
<h1>Communication avec socket.io !</h1>
<p><input type="button" value="Embêter le serveur" id="poke" /></p>
<input id="inputValue" type="text"/>
<button id="name">Submit</button>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
var socket = io.connect('http://localhost:8080');
$('#name').click(function(){
socket.emit('name', $( "#inputValue" ).val());
})
$('#poke').click(function () {
socket.emit('msg', 'Salut serveur, ça va ?');
})
socket.on('name', function(message){
console.log("OLA " + message);
})
</script>
</body>
</html>