-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
42 lines (40 loc) · 1.45 KB
/
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
34
35
36
37
38
39
40
41
42
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<h1>Hello World!</h1>
<div id="future"></div>
<form id="form" id="chat_form">
<input id="chat_input" type="text">
<input type="submit" value="Send">
</form>
<script src="/jquery/dist/jquery.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://10.1.220.19:4200');
//the socket.on('connect') event is on on successful connection from the web browser
socket.on('connect', function(data) {
//callback function that will send a msg upon successful connection from browser
socket.emit('join', 'Hello World from client');
});
socket.on('messages', function(data) {
alert(data);
});
</script>
<script>
var socket = io.connect();
socket.on('connect', function(data) {
socket.emit('join', 'Hello World from client');
});
socket.on('broad', function(data) {
$('#future').append(data+ "<br/>");
});
$('form').submit(function(e){
e.preventDefault();
var message = $('#chat_input').val();
socket.emit('messages', message);
});
</script>
</body>
</html>