<commit_before>var Thunder = new function() {
    this.channels = [];
    this.handlers = [];
    
    this.reconnect_delays = [1000, 2500, 5000, 10000, 30000, 60000];
    
    this.options = {
        // verbose?
        log: false
    };

    this.connect = function(server, apikey, channels, options) {
        this.server = "http://" + server + "/connect";
        this.apikey = apikey;
        this.channels = channels;

        // merge options
        for (var attr in options) {
            this.options[attr] = options[attr];
        }

        this.no_reconnect = false;
        this.user = this.options.user;
        this.makeConnection();

        var that = this;

        // add internal handler
        this.handlers.push(function(data) {
            if (data == 'WRONGKEY') {
                that.no_reconnect = true;
            }
        });
    };

    this.listen = function(handler) {
        this.log("New handler has been registered.");
        this.handlers.push(handler);
    };

    this.makeConnection = function() {
        var that = this;

        // make a connection
        this.socket = new SockJS(this.server, undefined, 
            {'debug': this.options.log});

        this.socket.onopen = function() {
            that.log("Connection has been estabilished.");

            // reset retries counter
            that.reconnect_tries = 0;

            // connect and subscribe to channels
            that.socket.send("CONNECT " + that.user + ":" + that.apikey);
            that.socket.send("SUBSCRIBE " + that.channels.join(":"));
        }

        this.socket.onmessage = function(e) {<commit_msg>Issue SUBSCRIBE only if channel list not empty<commit_after>var Thunder = new function() {
    this.channels = [];
    this.handlers = [];
    
    this.reconnect_delays = [1000, 2500, 5000, 10000, 30000, 60000];
    
    this.options = {
        // verbose?
        log: false
    };

    this.connect = function(server, apikey, channels, options) {
        this.server = "http://" + server + "/connect";
        this.apikey = apikey;
        this.channels = channels;

        // merge options
        for (var attr in options) {
            this.options[attr] = options[attr];
        }

        this.no_reconnect = false;
        this.user = this.options.user;
        this.makeConnection();

        var that = this;

        // add internal handler
        this.handlers.push(function(data) {
            if (data == 'WRONGKEY') {
                that.no_reconnect = true;
            }
        });
    };

    this.listen = function(handler) {
        this.log("New handler has been registered.");
        this.handlers.push(handler);
    };

    this.makeConnection = function() {
        var that = this;

        // make a connection
        this.socket = new SockJS(this.server, undefined, 
            {'debug': this.options.log});

        this.socket.onopen = function() {
            that.log("Connection has been estabilished.");

            // reset retries counter
            that.reconnect_tries = 0;

            // connect and subscribe to channels
            that.socket.send("CONNECT " + that.user + ":" + that.apikey);

            if (that.channels.length)
                that.socket.send("SUBSCRIBE " + that.channels.join(":"));
        }

        this.socket.onmessage = function(e) {
{'fraction_non_alphanumeric': 0.12880143112701253, 'fraction_numerical': 0.016696481812760882, 'mean_word_length': 1.7477477477477477, 'pattern_counts': {'":': 4, '<': 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': '1031845', 'n_tokens_mistral': 1017, 'n_tokens_neox': 931, 'n_words': 211}