var express = require('express');
var router = express.Router();
let io = require('../controllers/socketio');

const score = require('../controllers/score');
const etc = require('../controllers/etc');

/* GET home page. */
router.get('/', function(req, res, next) {
    if(etc.getSplashscreen()) {                     // If splashscreen is enabled
        res.render('splashscreen', {});             // Render splashscreen
    } else {
        if (score.getEnabled()) {                   // If scoreboard is enabled
            res.render('indexScore', {});           // Render the site with scoreboard
        } else {                                    // If scoreboard is not enabled
            res.render('index', {});                // Render the site without scoreboard
        }
    }
});

io.on('connection', (socket) => {
    console.log("A user connected");
    socket.emit("Hello user from server");

    socket.on('message', (message) => {
        console.log(message)
    })
})

module.exports = router;
