aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.js
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-07-21 23:33:04 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-07-21 23:33:04 +0530
commite4498c56048c44d1dae41d27c3213f94ccb027a8 (patch)
tree7ccb4ee7536ed58f01e9666868354b523d71c387 /src/server/index.js
parent166f8d4262729b2f771c30f8e71a305052cc13d5 (diff)
Implemented basic connection between client and server using websockets
Diffstat (limited to 'src/server/index.js')
-rw-r--r--src/server/index.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/server/index.js b/src/server/index.js
index 2b85ea5..f8b5ca7 100644
--- a/src/server/index.js
+++ b/src/server/index.js
@@ -1,11 +1,19 @@
const express = require('express');
-const path = require('path');
const app = express();
+const http = require('http').Server(app);
+const path = require('path');
+const io = require('socket.io')(http);
app.use(express.static(path.join(__dirname, '../../build')));
+io.on('connection', (socket) => {
+ socket.on('update-remote-board', (board) => {
+ io.emit('update-client-board', board)
+ })
+});
+
// Start the server
const PORT = process.env.PORT || 5000;
-app.listen(PORT, () => {
+http.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
});