<commit_before>var net = require('net');
var events = require('events');
var util = require('util');
var Speaker = require('speaker');

function Server(opts) {
	if (!(this instanceof Server)) return new Server(opts);
	events.EventEmitter.call(this);

	var that = this;

	var speaker = new Speaker({
		channels: 2,          // 2 channels
		bitDepth: 16,         // 16-bit samples
		sampleRate: 44100     // 44,100 Hz sample rate
	});
	that.speaker = speaker;

	this.server = net.createServer(function (conn) {
		that.emit('connection', conn);

		if (that.speaker) { // Another client already connected
			conn.end();
			return;
		}

		// PCM data from conn gets piped into the speaker
		conn.pipe(speaker);

		conn.on('end', function () {
			conn.unpipe(speaker);
		});
	}).listen(opts.port);
}
util.inherits(Server, events.EventEmitter);

module.exports = Server;<commit_msg>Bugfixes<commit_after>var net = require('net');
var events = require('events');
var util = require('util');
var Speaker = require('speaker');

function Server(opts) {
	if (!(this instanceof Server)) return new Server(opts);
	events.EventEmitter.call(this);

	var that = this;

	var speaker = new Speaker({
		channels: 2,          // 2 channels
		bitDepth: 16,         // 16-bit samples
		sampleRate: 44100     // 44,100 Hz sample rate
	});
	this.speaker = speaker;

	this.connected = false;

	this.server = net.createServer(function (conn) {
		that.emit('connection', conn);

		if (that.connected) { // Another client already connected
			conn.end();
			return;
		}

		// PCM data from conn gets piped into the speaker
		conn.pipe(speaker);

		that.connected = true;

		conn.on('end', function () {
			conn.unpipe(speaker);
			that.connected = false;
		});
	}).listen(opts.port);
}
util.inherits(Server, events.EventEmitter);

module.exports = Server;
{'fraction_non_alphanumeric': 0.1484118291347207, 'fraction_numerical': 0.017524644030668127, 'mean_word_length': 3.533498759305211, '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': '2585981', 'n_tokens_mistral': 652, 'n_tokens_neox': 570, 'n_words': 157}