<commit_before>'use strict';

/*
 * Socket.io related things go !
 */

import { log, LOG_TYPES } from './log';
import decodeJWT          from './decodeJWT';

const EVENT_TYPES = {
    DISCONNECT      : 'disconnect',
    CONNECTION      : 'connection',
    TOKEN_VALID     : 'token_valid',
    TOKEN_INVALID   : 'token_invalid',
    CONTACT_ONLINE  : 'contact:online',
    CONTACT_OFFLINE : 'contact:offline'
};

let io;

let connections = [];

function createSocketIO(server, app) {
    io = require('socket.io')(server);
    io.set('origins', '*');
    io.on(EVENT_TYPES.CONNECTION, (socket) => {

        socket.on(EVENT_TYPES.DISCONNECT, () => {
            log(`Socket disconnected with id ${socket.id}`, LOG_TYPES.WARN);

            var i = connections.indexOf(socket);
            connections.splice(i, 1);
        });

        decodeJWT(socket.handshake.query.token)
            .then( results => {<commit_msg>Specify what socket standards to use for communication<commit_after>'use strict';

/*
 * Socket.io related things go !
 */

import { log, LOG_TYPES } from './log';
import decodeJWT          from './decodeJWT';

const EVENT_TYPES = {
    DISCONNECT      : 'disconnect',
    CONNECTION      : 'connection',
    TOKEN_VALID     : 'token_valid',
    TOKEN_INVALID   : 'token_invalid',
    CONTACT_ONLINE  : 'contact:online',
    CONTACT_OFFLINE : 'contact:offline'
};

let io;

let connections = [];

function createSocketIO(server, app) {
    io = require('socket.io')(server, {'transports': ['websocket', 'polling']});
    io.set('origins', '*');
    io.on(EVENT_TYPES.CONNECTION, (socket) => {

        socket.on(EVENT_TYPES.DISCONNECT, () => {
            log(`Socket disconnected with id ${socket.id}`, LOG_TYPES.WARN);

            var i = connections.indexOf(socket);
            connections.splice(i, 1);
        });

        decodeJWT(socket.handshake.query.token)
            .then( results => {
{'fraction_non_alphanumeric': 0.1474726420010422, 'fraction_numerical': 0.0010422094841063053, 'mean_word_length': 2.7573385518590996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5247229', 'n_tokens_mistral': 623, 'n_tokens_neox': 617, 'n_words': 122}