Created
September 5, 2018 19:06
-
-
Save rupesh2017/29d0bcf165e0c1a39338717e323e7222 to your computer and use it in GitHub Desktop.
chat (room and user)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//code running on user machine | |
document.addEventListener('DOMContentLoaded',()=>{ | |
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port); | |
socket.on('connect',()=>{ | |
document.querySelector('#submit').onclick= ()=>{ | |
const user = document.querySelector('#user').value; | |
const room = document.querySelector('#room').value; | |
socket.emit('join',{'user':user,'room':room}); | |
return false; | |
}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment