<commit_before>var net = require('net');
var pid = "/var/run/mtcr.pid";
var port = 42581;
var version = {
    protocol: 0x1,
    server: "0.1.0",
    client: "0.0.0"
};

var clients = [];

for (var i = 0; i < 256; ++i) {
    clients[i] = {
        socket: null,
        nickname: null,
        state: 0, // 0 = disconnected, 1 = connected, 2 = joined, 3 = wait for pw
    };
}

var strToBin = function(str) {
    return new Buffer(str);
};

var numToBin = function(len,num) {
    var b = new Buffer(len);
    while (len--) {
        b[len] = num % 256;
        num /= 256;
    }
    return b;
}

var getMinDisconnectedUID = function() {
    for (var i = 0; i < 256; ++i)
        if (clients[i].state == 0)
            return i;
    return -1;
};

var sendToAllClients = function(pkg) {
    for (var uuid in clients) {
        clients[uuid].socket.write(pkg);
    }
}

var cmpBin = function(len, a, b) {
    for (var i = 0; i < len; ++i)
        if (a[i] - b[i]) return i;
    return -1;
}

var getPkg = {
    version: function() {
        return new Buffer(
            "MTCR" + numToBin(1, version.protocol) + "\x00"
            + numToBin(1, version.client.length) + version.client
            + numToBin(1, version.server.length) + version.server
        );
    },
    loginOk: function() {
        return new Buffer(
            "MTCR" + numToBin(1, version.protocol) + "\x10"<commit_msg>fix send to all bug<commit_after>var net = require('net');
var pid = "/var/run/mtcr.pid";
var port = 42581;
var version = {
    protocol: 0x1,
    server: "0.1.0",
    client: "0.0.0"
};

var clients = [];

for (var i = 0; i < 256; ++i) {
    clients[i] = {
        socket: null,
        nickname: null,
        state: 0, // 0 = disconnected, 1 = connected, 2 = joined, 3 = wait for pw
    };
}

var strToBin = function(str) {
    return new Buffer(str);
};

var numToBin = function(len,num) {
    var b = new Buffer(len);
    while (len--) {
        b[len] = num % 256;
        num /= 256;
    }
    return b;
}

var getMinDisconnectedUID = function() {
    for (var i = 0; i < 256; ++i)
        if (clients[i].state == 0)
            return i;
    return -1;
};

var sendToAllClients = function(pkg) {
    for (var uuid in clients) {
        if (clients[uuid].state == 2) {
            clients[uuid].socket.write(pkg);
        }
    }
}

var cmpBin = function(len, a, b) {
    for (var i = 0; i < len; ++i)
        if (a[i] - b[i]) return i;
    return -1;
}

var getPkg = {
    version: function() {
        return new Buffer(
            "MTCR" + numToBin(1, version.protocol) + "\x00"
            + numToBin(1, version.client.length) + version.client
            + numToBin(1, version.server.length) + version.server
        );
    },
    loginOk: function() {
        return new Buffer(
            "MTCR" + numToBin(1, version.protocol) + "\x10"
{'fraction_non_alphanumeric': 0.16068917018284107, 'fraction_numerical': 0.03129395218002813, 'mean_word_length': 1.9947368421052631, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2031832', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1033, 'n_words': 278}