VoiceBroadcast.{dispatchers -> subscribers}

This commit is contained in:
Amish Shah
2019-05-12 20:29:28 +01:00
parent 75d5598fda
commit 72dd872fce
2 changed files with 9 additions and 9 deletions

View File

@@ -28,10 +28,10 @@ class VoiceBroadcast extends EventEmitter {
*/
this.client = client;
/**
* The dispatchers playing this broadcast
* The subscribed StreamDispatchers of this broadcast
* @type {StreamDispatcher[]}
*/
this.dispatchers = [];
this.subscribers = [];
this.player = new BroadcastAudioPlayer(this);
}
@@ -66,19 +66,19 @@ class VoiceBroadcast extends EventEmitter {
* Ends the broadcast, unsubscribing all subscribed channels and deleting the broadcast
*/
end() {
for (const dispatcher of this.dispatchers) this.delete(dispatcher);
for (const dispatcher of this.subscribers) this.delete(dispatcher);
const index = this.client.voice.broadcasts.indexOf(this);
if (index !== -1) this.client.voice.broadcasts.splice(index, 1);
}
add(dispatcher) {
const index = this.dispatchers.indexOf(dispatcher);
const index = this.subscribers.indexOf(dispatcher);
if (index === -1) {
this.dispatchers.push(dispatcher);
this.subscribers.push(dispatcher);
/**
* Emitted whenever a stream dispatcher subscribes to the broadcast.
* @event VoiceBroadcast#subscribe
* @param {StreamDispatcher} dispatcher The subscribed dispatcher
* @param {StreamDispatcher} subscriber The subscribed dispatcher
*/
this.emit(Events.VOICE_BROADCAST_SUBSCRIBE, dispatcher);
return true;
@@ -88,9 +88,9 @@ class VoiceBroadcast extends EventEmitter {
}
delete(dispatcher) {
const index = this.dispatchers.indexOf(dispatcher);
const index = this.subscribers.indexOf(dispatcher);
if (index !== -1) {
this.dispatchers.splice(index, 1);
this.subscribers.splice(index, 1);
dispatcher.destroy();
/**
* Emitted whenever a stream dispatcher unsubscribes to the broadcast.

View File

@@ -15,7 +15,7 @@ class BroadcastDispatcher extends StreamDispatcher {
_write(chunk, enc, done) {
if (!this.startTime) this.startTime = Date.now();
for (const dispatcher of this.broadcast.dispatchers) {
for (const dispatcher of this.broadcast.subscribers) {
dispatcher._write(chunk, enc);
}
this._step(done);