diff --git a/swarmlab-app/src/package.json b/swarmlab-app/src/package.json index 8fcd6f0..5c71f91 100644 --- a/swarmlab-app/src/package.json +++ b/swarmlab-app/src/package.json @@ -14,6 +14,9 @@ "chai": "^4.2.0", "cors": "^2.8.5", "dirty-chai": "^2.0.1", + "socket.io-redis": "^6.0.1", + "redis": "^3.0.0", + "socket.io-adapter": "~2.0.0", "express": "^4.17.1", "express-validator": "^6.6.1", "helmet": "^4.1.1", diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index 961f992..b8a7540 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -6,6 +6,14 @@ var http = require('http').Server(app); var https = require('https'); var io = require('socket.io')(http); +import { createAdapter } from 'socket.io-redis'; +import { RedisClient } from 'redis'; + +const pubClient = new RedisClient({ host: 'localhost', port: 6379 }); +const subClient = pubClient.duplicate(); + +io.adapter(createAdapter({ pubClient, subClient })); + const MongoClient = require('mongodb').MongoClient; //var chokidar = require("chokidar");