From 6d064cec4b970986263e512fb9230d870a067bea Mon Sep 17 00:00:00 2001 From: Mizanali Panjwani Date: Mon, 22 Feb 2021 06:33:25 +0530 Subject: [PATCH] Communicated game logic over socketio server --- server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.js b/server.js index e107c69..3f94a02 100644 --- a/server.js +++ b/server.js @@ -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') })