From 9e7b04d4b173daeea9e217594f44c8a6a3a323a4 Mon Sep 17 00:00:00 2001 From: velvettear Date: Mon, 2 May 2022 15:03:07 +0200 Subject: [PATCH] some minor fixes, removal of unused code, etc. --- classes/AudioBuffer.js | 2 +- classes/Audiostream.js | 4 ++++ classes/Connection.js | 13 ++++++------- example_config.json | 5 ++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/classes/AudioBuffer.js b/classes/AudioBuffer.js index ff2d321..ae063d8 100644 --- a/classes/AudioBuffer.js +++ b/classes/AudioBuffer.js @@ -54,7 +54,7 @@ class StreamBuffer extends EventEmitter { announced: false }; this.limit = { - value: config?.buffer?.limit, + value: config?.buffer?.limit * 1048576, announced: false }; if (isNaN(this.limit.value) || this.limit.value < this.threshold.value) { diff --git a/classes/Audiostream.js b/classes/Audiostream.js index 37ddef6..1252c13 100644 --- a/classes/Audiostream.js +++ b/classes/Audiostream.js @@ -75,6 +75,10 @@ class Audiostream { logger.info('connection to audio server \'' + this.getTag() + '\' closed'); }); } + + destroy() { + + } } module.exports = Audiostream; \ No newline at end of file diff --git a/classes/Connection.js b/classes/Connection.js index 4ec5ba8..90c63ed 100644 --- a/classes/Connection.js +++ b/classes/Connection.js @@ -16,6 +16,8 @@ class Connection { } this.host = config?.server?.host || "127.0.0.1"; this.port = config?.server?.port || "3000"; + this.eventParser = new EventParser(); + this.audiostream = new Audiostream(this.eventParser); } getHost() { @@ -51,8 +53,6 @@ class Connection { #handleEventConnect(resolve, socket) { logger.info('connected to communication server \'' + this.getTag() + '\'...'); this.socket = socket; - this.eventParser = new EventParser(); - this.audiostream = new Audiostream(this.eventParser); this.heartbeat = new Heartbeat(this.eventParser); this.#handleHeartbeat(); socket.on('timeout', () => { @@ -91,11 +91,6 @@ class Connection { }); } - #handleAudioEvents() { - - - } - destroy() { if (this.heartbeat !== undefined) { this.heartbeat.destroy(); @@ -112,6 +107,10 @@ class Connection { this.socket.destroy(); this.socket = undefined; } + if (this.audiostream !== undefined) { + this.audiostream.destroy(); + + } } } diff --git a/example_config.json b/example_config.json index f1275ff..2504af6 100644 --- a/example_config.json +++ b/example_config.json @@ -13,7 +13,6 @@ "delay": 1000 }, "buffer": { - "limit": 40960 - }, - "tmp": "/tmp/kannon.tmp" + "limit": 64 + } } \ No newline at end of file