<commit_before>var topicName;
var topics = {};
var titlePrefix = "MQTT Wall";


// --- Application objects ----------------------------------------------------


function WallClient(host, port, path)
{
    var that = this;
    var clientId = "wall-" + new Date().getTime();
    var client = new Paho.MQTT.Client(host, port, path, clientId);
    var connectOptions = {};

    client.onMessageArrived = function (message) {
        console.log("Message arrived ", message);

        that.onMessage(message.destinationName, message.payloadString, message.retained);
    };

    client.onConnectionLost = function (error) {
        console.info("Connection lost, ", error);

        that.onError("Connection lost (" + error.errorMessage + ")", true);
    }

    connectOptions.onSuccess = function () {
        console.info("Connect success");
        that.onConnected();
    }

    connectOptions.onFailure = function (error) {
        console.error("MQTT connect fail ", error);

        that.onError("Fail to connect", true);
    }

    client.connect(connectOptions);

    this._client = client;
    this.currentTopic = null;
}

// events
WallClient.prototype.onConnected = $.noop();
WallClient.prototype.onMessage = $.noop();
WallClient.prototype.onError = $.noop();

WallClient.prototype.subscribe = function (topic, fn) {
    console.log("begin subscribe");
    var that = this;

    // unsubscribe current topic (if exists)
    if (this.currentTopic !== null) {
        var oldTopic = this.currentTopic;
        this._client.unsubscribe(oldTopic, {
            onSuccess: function(){
                console.info("Unsubscribe '%s' success", oldTopic);
            },
            onFailure: function(error){
                console.error("Unsubscribe '%s' failure", oldTopic, error);
            },
        });
    }
  
    // subscribe new topic
    that._client.subscribe(topic, {
        onSuccess: function (r) {
            console.info("subscribe success", r);
            fn();
        },
        onFailure: function (r) {
            console.error("subscribe failure", r);<commit_msg>Typo (#11)<commit_after>var topicName;
var topics = {};
var titlePrefix = "MQTT Wall";


// --- Application objects ----------------------------------------------------


function WallClient(host, port, path)
{
    var that = this;
    var clientId = "wall-" + new Date().getTime();
    var client = new Paho.MQTT.Client(host, port, path, clientId);
    var connectOptions = {};

    client.onMessageArrived = function (message) {
        //console.log("Message arrived ", message);
        that.onMessage(message.destinationName, message.payloadString, message.retained);
    };

    client.onConnectionLost = function (error) {
        console.info("Connection lost ", error);
        that.onError("Connection lost (" + error.errorMessage + ")", true);
    }

    connectOptions.onSuccess = function () {
        console.info("Connect success");
        that.onConnected();
    }

    connectOptions.onFailure = function (error) {
        console.error("Connect fail ", error);
        that.onError("Fail to connect", true);
    }

    client.connect(connectOptions);

    this._client = client;
    this.currentTopic = null;
}

// events
WallClient.prototype.onConnected = $.noop();
WallClient.prototype.onMessage = $.noop();
WallClient.prototype.onError = $.noop();

WallClient.prototype.subscribe = function (topic, fn) {
    var that = this;

    // unsubscribe current topic (if exists)
    if (this.currentTopic !== null) {
        var oldTopic = this.currentTopic;
        this._client.unsubscribe(oldTopic, {
            onSuccess: function(){
                console.info("Unsubscribe '%s' success", oldTopic);
            },
            onFailure: function(error){
                console.error("Unsubscribe '%s' failure", oldTopic, error);
            },
        });
    }
  
    // subscribe new topic
    that._client.subscribe(topic, {
        onSuccess: function (r) {
            console.info("Subscribe '%s' success", topic, r);
            fn();
        },
        onFailure: function (r) {
            console.error("subscribe '%s' failure", topic, r);
{'fraction_non_alphanumeric': 0.15930902111324377, 'fraction_numerical': 0.0004798464491362764, 'mean_word_length': 2.327214684756584, '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': '5027755', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1106, 'n_words': 259}