<commit_before>module.exports = function(myApp) {
    var nsp_draft = myApp.webserver.io.of('/draft');
    nsp_draft.on('connection', function(socket){
        myApp.utils.consoleOutput("Connection on socket.io/draft for socket " + socket.id);

        socket.custom = {
            room: null,
            isAdmin: false
        };

        socket.on('join', function(data) {
            // Slight obfuscation for clients
            if (typeof data === "string") { data = { room: data }; }

            if (socket.custom.room) {
              console.log("socket " + socket.id + " left " + socket.custom.room);
              socket.leave(socket.custom.room);
            }

            socket.join(data.room);
            socket.custom.room = data.room;

            console.log("socket " + socket.id + " joined " + socket.custom.room);
            socket.emit('joined', socket.custom.room);

            if ((typeof data === "object") && (data.admin === true)) {
                console.log("socket is admin");
                socket.custom.isAdmin = true;
            }

            // TODO: Send data for room to socket
        });

        socket.on('broadcast', function(message) {
            if (!socket.custom.isAdmin) {
                return;
            }
            nsp_draft.in(socket.custom.room).emit(message.event, message.data);
        });

    });

    myApp.utils.consoleOutput("module/sockets/draft has been loaded...");
};<commit_msg>fix - rename draft to livedraft<commit_after>module.exports = function(myApp) {
    var nsp_draft = myApp.webserver.io.of('/livedraft');
    nsp_draft.on('connection', function(socket){
        myApp.utils.consoleOutput("Connection on socket.io/livedraft for socket " + socket.id);

        socket.custom = {
            room: null,
            isAdmin: false
        };

        socket.on('join', function(data) {
            // Slight obfuscation for clients
            if (typeof data === "string") { data = { room: data }; }

            if (socket.custom.room) {
              console.log("socket " + socket.id + " left " + socket.custom.room);
              socket.leave(socket.custom.room);
            }

            socket.join(data.room);
            socket.custom.room = data.room;

            console.log("socket " + socket.id + " joined " + socket.custom.room);
            socket.emit('joined', socket.custom.room);

            if ((typeof data === "object") && (data.admin === true)) {
                console.log("socket is admin");
                socket.custom.isAdmin = true;
            }

            // TODO: Send data for room to socket
        });

        socket.on('broadcast', function(message) {
            if (!socket.custom.isAdmin) {
                return;
            }
            nsp_draft.in(socket.custom.room).emit(message.event, message.data);
        });

    });

    myApp.utils.consoleOutput("module/sockets/livedraft has been loaded...");
};
{'fraction_non_alphanumeric': 0.14348710990502037, 'fraction_numerical': 0.0, 'mean_word_length': 1.7742238946378175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5602288', 'n_tokens_mistral': 832, 'n_tokens_neox': 801, 'n_words': 156}