<commit_before>var mysql = require('mysql');
var mysql = mysql.createConnection({
    host     : '10.32.195.171',
    user     : 'quizz',
    password : '<PASSWORD>',
    database : 'quizz'
});
mysql.connect();
var io = require('socket.io')(1234);// --> créer le server websocket -> module socket.io (npm install socket.io) npm = node package manager
var question;
var reponse;
var timer = 0;
setInterval(function()
{
    if (timer == 1)
    {
        mysql.query("SELECT question, reponse FROM questions ORDER BY RAND() LIMIT 1", function(err, rows, fields)
        {
            if (!err)
            {
                question = rows[0]['question'];
                reponse = rows[0]['reponse'];
                io.emit('question', question);
            }
            else
                console.log(err);
        });
    }
    else if (timer == 10)
    {
        io.emit('end', reponse);
    }
    else if (timer > 15)
        timer = 0;
    if (timer <= 10)
        io.emit('timer', timer);
    timer++;
}, 1000);
io.on('connection', function (socket)// -> "quand il a une nouvelle connexion" -> appeler la fonction(socket) -> socket = connexion de l'utilisateur
{
    console.log('new connection');// informer admin nouvelle connexion
    socket.on('login', function(login)
    {
        console.log('Bonjour ', login);
        mysql.query("SELECT id, name, score FROM user WHERE name=?", [login], function(err, rows, fields)
        {
            if (!err)
            {
                if (rows[0] == undefined)
                {
                    console.log('Creation de '+login);
                    mysql.query("INSERT INTO user (name) VALUES (?)", [login], function(err, rows, fields)
                    {
                        socket.login = login;
                        socket.score = 0;
                        socket.emit('logged', login, 0);
                    });
                }
                else
                {
                    socket.login = login;
                    socket.score = rows[0]['score'];
                    socket.emit('logged', login, rows[0]['score']);
                }
            }
            else
                console.log(err);
        });
    });
    socket.emit('connected');// envoyer a la socket (navigateur/utilisateur/client/...) le message "connected"
});<commit_msg>maj server + client<commit_after>var mysql = require('mysql');
var mysql = mysql.createConnection({
    host     : '10.32.195.171',
    user     : 'quizz',
    password : '<PASSWORD>',
    database : 'quizz'
});
mysql.connect();
var io = require('socket.io')(1234);// --> créer le server websocket -> module socket.io (npm install socket.io) npm = node package manager
var question;
var reponse;
var timer = 0;
var score = 5;
setInterval(function()
{
    if (timer == 0)
    {
        mysql.query("SELECT question, reponse FROM questions ORDER BY RAND() LIMIT 1", function(err, rows, fields)
        {
            if (!err)
            {
                question = rows[0]['question'];
                reponse = rows[0]['reponse'];
                io.emit('question', question);
                score = 5;
            }
            else
                console.log(err);
        });
    }
    else if (timer == 10)
    {
        io.emit('end', reponse);
    }
    else if (timer > 15)
        timer = -1;
    timer++;
    if (timer <= 10)
        io.emit('timer', timer);
}, 1000);
io.on('connection', function (socket)// -> "quand il a une nouvelle connexion" -> appeler la fonction(socket) -> socket = connexion de l'utilisateur
{
    console.log('new connection');// informer admin nouvelle connexion
    socket.on('login', function(login)
    {
        console.log('Bonjour ', login);
        mysql.query("SELECT id, name, score FROM user WHERE name=?", [login], function(err, rows, fields)
        {
            if (!err)
            {
                if (rows[0] == undefined)
                {
                    console.log('Creation de '+login);
                    mysql.query("INSERT INTO user (name) VALUES (?)", [login], function(err, rows, fields)
                    {
                        socket.login = login;
                        socket.score = 0;
                        socket.emit('logged', login, 0);
                    });
                }
                else
                {
                    socket.login = login;
                    socket.score = rows[0]['score'];
                    socket.emit('logged', login, rows[0]['score']);
                }
            }
            else
                console.log(err);
        });
    });
    socket.on('reponse', function(reponse_user)
    {
        if (reponse_user == reponse)
        {
            socket.score = socket.score + score;
            score--;
            mysql.query("UPDATE user SET score=? WHERE name=?", [socket.score, socket.login], function(err, rows, fields)
            {
                socket.emit('score', socket.score);
            });
        }
        else
        {
            socket.score = socket.score - 1;
            mysql.query("UPDATE user SET score=? WHERE name=?", [socket.score, socket.login], function(err, rows, fields)
            {
                socket.emit('score', socket.score);
            });
        }
    });
    socket.emit('connected');// envoyer a la socket (navigateur/utilisateur/client/...) le message "connected"
});
{'fraction_non_alphanumeric': 0.14238165680473372, 'fraction_numerical': 0.013498520710059171, 'mean_word_length': 1.5514150943396225, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2285795', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1448, 'n_words': 376}