From 2e3187e795b041ccbd71e24ffe6d5b5e6e9f1a7d Mon Sep 17 00:00:00 2001 From: zeus Date: Sat, 28 Nov 2020 21:15:52 +0200 Subject: [PATCH] async --- swarmlab-app/src/run/app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index 891aa0c..e283959 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -24,6 +24,7 @@ const io = require("socket.io")(http, { } }); +/* const Redis = require("ioredis"); const redistest = new Redis({ host: 'redisserver', @@ -33,14 +34,16 @@ const pubtest = new Redis({ host: 'redisserver', port: 6379, }); - +*/ //import { createAdapter } from 'socket.io-redis'; const createAdapter = require('socket.io-redis'); //import { RedisClient } from 'redis'; -const RedisClient = require("redis"); -const pubClient = RedisClient.createClient({ +//const RedisClient = require("redis"); +const Redis = require("ioredis"); +//const pubClient = RedisClient.createClient({ +const pubClient = new Redis({ host: 'redisserver', port: 6379, }); @@ -517,7 +520,10 @@ function onCollection(err, collection) { var user = resob1.res25creator //io.in(user).emit("logdata", reslog); //var user = 'anagnostopoulos@uniwa.gr' - pubtest.publish(user, reslog); + pubClient.get(issend).then(function (result) { + console.log(result); // Prints "bar" + io.in(user).emit("logdata", reslog); + }); pubClient.get(issend, function(err, object) { if(err == null){ pubClient.set(issend, itemsProcessed, function(err, res) { @@ -611,9 +617,6 @@ io.on('connection', s => { var room = usersession.SOCKET.user //s.on("subscribe", function (room) { s.join(room); -redistest.subscribe(room, (err, count) => { - pubtest.publish(room, "Hello world!"); -}); console.log("joining rooom", s.rooms); console.log(room + ' created ') // });