I am trying to access data of socket.id outside of io.on()
function...
with io.on('connection')
I counted every each user logged in my app and put in an array, but I want to send different pages according to the socket.id that each user have.
How can I achieve this?
[...]
var row_of_users = [];//my array of users.
var visits = 0;//just a count of users logged in.
io.on('connection', function(socket){
var user = socket.id;
visits++;
row_of_users.push(user);
console.log(row_of_users);
[...]
Outside of the function I have my express function:
app.get('/', function(req, res) {
if(row_of_users == 0) {
res.sendFile(__dirname+'/index.html');
} else if (row_of_users < 0) {
res.sendFile(__dirname+'/wait-your-time.html');
}