auth/auth.js
function authPlayers(channel, info) {

        var code, player, token;
        playerId = info.cookies.player;
        token = info.cookies.token;


        // Code not existing.
        if (!code) {
            console.log('not existing token: ', token);
            return false;
        }

        if (code.checkedOut) {
            console.log('token was already checked out: ', token);
            return false;
        }

        // Code in use.
        //  usage is for LOCAL check, IsUsed for MTURK
        if (code.valid === false) {
            if (code.disconnected) {
                return true;
            }
            else {
                console.log('token already in use: ', token);
                return false;
            }
        }

        // Client Authorized
        return true;
    }
function authPlayers(channel, info) {

        var code, player, token;
        playerId = info.cookies.player;
        token = info.cookies.token;


        // Code not existing.
        if (!code) {
            console.log('not existing token: ', token);
            return false;
        }

        if (code.checkedOut) {
            console.log('token was already checked out: ', token);
            return false;
        }

        // Code in use.
        //  usage is for LOCAL check, IsUsed for MTURK
        if (code.valid === false) {
            if (code.disconnected) {
                return true;
            }
            else {
                console.log('token already in use: ', token);
                return false;
            }
        }

        // Client Authorized
        return true;
    }
function authPlayers ( channel , info ) { var code , player , token ; playerId = info . cookies . player ; token = info . cookies . token ; // Code not existing. if ( ! code ) { console . log ( 'not existing token: ' , token ) ; return false ; } if ( code . checkedOut ) { console . log ( 'token was already checked out: ' , token ) ; return false ; } // Code in use. //  usage is for LOCAL check, IsUsed for MTURK if ( code . valid === false ) { if ( code . disconnected ) { return true ; } else { console . log ( 'token already in use: ' , token ) ; return false ; } } // Client Authorized return true ; }
Creating an authorization function for the players. This is executed before the client the PCONNECT listener. Here direct messages to the client can be sent only using his socketId property, since no clientId has been created yet.
Creating an authorization function for the players . This is executed before the client the PCONNECT listener . Here direct messages to the client can be sent only using his socketId property since no clientId has been created yet .