Browse Source

async

master
zeus 4 years ago
parent
commit
2e3187e795
  1. 17
      swarmlab-app/src/run/app.js

17
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 ')
// });

Loading…
Cancel
Save