Created
June 15, 2020 13:53
-
-
Save teyyihan/ea17f6775418715dba67a0af7f4cd60a to your computer and use it in GitHub Desktop.
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
mongoose.connect('mongodb://localhost:27017/realtimeProject',{useNewUrlParser:true}, | |
function(err){ | |
if(err){ | |
throw err | |
} | |
console.log('Database connected') | |
io.on('connection',(socket)=>{ | |
console.log('user connected') | |
socket.on('joinRoom',(data)=>{ // data will look like => {myID: "123123"} | |
console.log('user joined room') | |
socket.join(data.myID) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment