<commit_before>function WebsocketHelper() {
	var self = this;
	this.connected = false;
	this.listener = [];
	this.reconnect();
}
WebsocketHelper.prototype.onmsg = function(e){
	var msg = e.data;
	for(var i=0;i<this.listener.length;i++) {
		if(msg.startsWith(this.listener[i].cmd) && typeof(this.listener[i].callback) == "function") {
			this.listener[i].callback(msg);
		}
	}
};
WebsocketHelper.prototype.on = function(cmd, callback) {
	if(typeof(cmd) == "undefined") return;
	if(typeof(callback) != "function") return;

	this.listener.push({ "cmd": cmd, "callback": callback });
	if(this.connected) this.subscribe(cmd)
}
WebsocketHelper.prototype.send = function(message) {
	if(typeof(message) != 'string') return;
	this.connection.send(message);
}
WebsocketHelper.prototype.subscribe = function(cmd) {
	this.connection.send(':subscribe:' + cmd)
}
WebsocketHelper.prototype.reconnect = function() {
	var self = this;
	this.connection = new WebSocket('ws://' + document.location.hostname + ':{__WS_PORT__}/');
	this.connection.onopen = function() {
		self.connected = true;
		for(var i=0;i<self.listener.length;i++) {
			self.subscribe(self.listener[i].cmd)
		}
		self.send(':please_repeat');
	}
	this.connection.onmessage = function(e){self.onmsg(e);};<commit_msg>Allow overlays to listen for websocket to connect<commit_after>function WebsocketHelper() {
	var self = this;
	this.connected = false;
	this.listener = [];
	this.reconnect();
}
WebsocketHelper.prototype.onmsg = function(e){
	var msg = e.data;
	for(var i=0;i<this.listener.length;i++) {
		if(msg.startsWith(this.listener[i].cmd) && typeof(this.listener[i].callback) == "function") {
			this.listener[i].callback(msg);
		}
	}
};
WebsocketHelper.prototype.on = function(cmd, callback) {
	if(typeof(cmd) == "undefined") return;
	if(typeof(callback) != "function") return;

	this.listener.push({ "cmd": cmd, "callback": callback });
	if(cmd != ':open' && this.connected) this.subscribe(cmd)
}
WebsocketHelper.prototype.send = function(message) {
	if(typeof(message) != 'string') return;
	this.connection.send(message);
}
WebsocketHelper.prototype.subscribe = function(cmd) {
	this.connection.send(':subscribe:' + cmd)
}
WebsocketHelper.prototype.reconnect = function() {
	var self = this;
	this.connection = new WebSocket('ws://' + document.location.hostname + ':{__WS_PORT__}/');
	this.connection.onopen = function() {
		self.connected = true;
		for(var i=0;i<self.listener.length;i++) {
			self.subscribe(self.listener[i].cmd)
		}
		self.send(':please_repeat');
		self.onmsg({data: ':open'})
	}
	this.connection.onmessage = function(e){self.onmsg(e);};
{'fraction_non_alphanumeric': 0.18439173680183626, 'fraction_numerical': 0.001530221882172915, 'mean_word_length': 5.45679012345679, 'pattern_counts': {'":': 4, '<': 7, '<?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': '7369422', 'n_tokens_mistral': 918, 'n_tokens_neox': 904, 'n_words': 142}