<commit_before>window.AudioContext = window.AudioContext || window.webkitAudioContext;

var DEBUG = true;

if (!DEBUG) {
    console.log = function() {

    }
    console.info = function() {

    }
    console.warn = function() {

    }
}

var socket = io();
socket.on('command', function (command) {
    window[command.wall].motors.forEach(function(motor, index) {
        motor.sendCommand(command.motors[index]);
    });
});

var checkSocketStatus = function() {
    if(leftGui && checkSocketStatus.lastStatus !== socket.connected) {
        var color, text;
        if(socket.connected) {
            color = '#00E029';
            text = 'Alive\'n\'kickin\'';
        } else {
            color = '#CC0000';
            text = 'Something is wrong!'
            notifications.fire('Socket Status', 'Connection lost!');
        }
        leftGui.updateStatusForSocket(color, text);
        checkSocketStatus.lastStatus = socket.connected;
    }
}

setInterval(checkSocketStatus, 1000);<commit_msg>Add watchdog for Server commands<commit_after>window.AudioContext = window.AudioContext || window.webkitAudioContext;

var DEBUG = true;

if (!DEBUG) {
    console.log = function() {

    }
    console.info = function() {

    }
    console.warn = function() {

    }
}

var lastCommand = Date.now();
var socket = io();
socket.on('command', function (command) {
    lastCommand = Date.now();
    window[command.wall].motors.forEach(function(motor, index) {
        motor.sendCommand(command.motors[index]);
    });
});

var checkStatuses = function() {
    if(leftGui && checkStatuses.lastSocketStatus !== socket.connected) {
        var color, text;
        if(socket.connected) {
            color = '#00E029';
            text = 'Alive\'n\'kickin\'';
        } else {
            color = '#CC0000';
            text = 'Something is wrong!'
            notifications.fire('Socket Status', 'Connection lost!');
        }
        leftGui.updateStatusForSocket(color, text);
        checkStatuses.lastSocketStatus = socket.connected;
    }

    if(socket.connected) {
        if(Date.now() - lastCommand >= 1000) {
            if(checkStatuses.lastCommandStatus) {
                leftGui.updateStatusForServer('#CC0000', 'Too quiet!');
                notifications.fire('Server Status', 'Isn\'t as fast as we expected!');
                checkStatuses.lastCommandStatus = false;
            }
        } else {
            leftGui.updateStatusForServer('#00E029', 'Healthy as fuck');
            checkStatuses.lastCommandStatus = true;
        }
    }
};

checkStatuses.lastCommandStatus = true;

setInterval(checkStatuses, 1000);
{'fraction_non_alphanumeric': 0.13650190114068442, 'fraction_numerical': 0.014828897338403042, 'mean_word_length': 2.5220883534136544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4881805', 'n_tokens_mistral': 789, 'n_tokens_neox': 741, 'n_words': 143}