Skip to content

Instantly share code, notes, and snippets.

@teyyihan
Created June 15, 2020 13:53
Show Gist options
  • Save teyyihan/ea17f6775418715dba67a0af7f4cd60a to your computer and use it in GitHub Desktop.
Save teyyihan/ea17f6775418715dba67a0af7f4cd60a to your computer and use it in GitHub Desktop.
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