This website works better with JavaScript.
Home
Explore
Help
Sign In
Mobile-Devices-ITM
/
socket-io-chat
generated from
gmarx/git-template
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Projects
0
Releases
0
Wiki
Activity
Browse Source
broadcasting
master
Gerardo Marx Chávez-Campos
2 years ago
parent
c84088e69d
commit
74a5264c14
2 changed files
with
9 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+7
-0
index.html
+2
-0
index.js
+ 7
- 0
index.html
View File
@ -33,6 +33,13 @@
input.value = '';
}
});
socket.on('chat message', function(msg) {
var item = document.createElement('li');
item.textContent = msg;
messages.appendChild(item);
window.scrollTo(0, document.body.scrollHeight);
});
<
/
script
>
<
/
body
>
<
/
html
>
+ 2
- 0
index.js
View File
@ -16,7 +16,9 @@ io.on('connection', (socket) => {
}
)
;
socket
.
on
(
'chat message'
,
(
msg
)
=>
{
console
.
log
(
'message: '
+
msg
)
;
io
.
emit
(
'chat message'
,
msg
)
;
}
)
;
}
)
;
server
.
listen
(
3030
,
(
)
=>
{
Write
Preview
Loading…
Cancel
Save