-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
34 lines (30 loc) · 752 Bytes
/
index.html
File metadata and controls
34 lines (30 loc) · 752 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
<html>
<head>
<title></title>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:3000');
socket.on('connect', function ()
{
var username = prompt('What is your nickname?');
socket.emit('set nickname', username);
socket.on('ready', function ()
{
console.log('Connected !');
var message = prompt('What is your message?');
socket.emit('msg', message);
document.getElementById('feed').innerHTML += '<br/>' + username + ': ' + message;
});
socket.on('msg', function (msg)
{
document.getElementById('feed').innerHTML += '<br/>' + msg.name + ': ' + msg.message;
});
});
</script>
</head>
<body>
<div id="feed">
</div>
Hello World...
</body>
</html>