Communicated game logic over socketio server

This commit is contained in:
Mizanali Panjwani 2021-02-22 06:33:25 +05:30
parent 4264810032
commit 6d064cec4b
1 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,14 @@ app.use(cors())
io.on('connection', socket => {
console.log('connection made')
socket.on('initGameState', gameState => {
io.emit('initGameState', gameState)
})
socket.on('updateGameState', gameState => {
io.emit('updateGameState', gameState)
})
socket.on('disconnect', () => {
console.log('connection lost')
})