mirror of
https://github.com/danbulant/discord.js
synced 2026-06-08 17:21:31 +00:00
Implement Receiver debug events
This commit is contained in:
parent
83140f11b7
commit
cb161a8a40
4 changed files with 11 additions and 11 deletions
|
|
@ -415,11 +415,6 @@ class VoiceConnection extends EventEmitter {
|
||||||
const guild = this.channel.guild;
|
const guild = this.channel.guild;
|
||||||
const user = this.client.users.get(user_id);
|
const user = this.client.users.get(user_id);
|
||||||
this.ssrcMap.set(+ssrc, user);
|
this.ssrcMap.set(+ssrc, user);
|
||||||
if (!speaking) {
|
|
||||||
for (const receiver of this.receivers) {
|
|
||||||
receiver.stoppedSpeaking(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Emitted whenever a user starts/stops speaking.
|
* Emitted whenever a user starts/stops speaking.
|
||||||
* @event VoiceConnection#speaking
|
* @event VoiceConnection#speaking
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,10 @@ class PacketHandler {
|
||||||
const stream = this.streams.get(user.id);
|
const stream = this.streams.get(user.id);
|
||||||
if (!stream) return;
|
if (!stream) return;
|
||||||
const opusPacket = this.parseBuffer(buffer);
|
const opusPacket = this.parseBuffer(buffer);
|
||||||
if (opusPacket instanceof Error) return;
|
if (opusPacket instanceof Error) {
|
||||||
|
this.emit('error', opusPacket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
stream.push(opusPacket);
|
stream.push(opusPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ class VoiceReceiver extends EventEmitter {
|
||||||
super();
|
super();
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.packets = new PacketHandler(this);
|
this.packets = new PacketHandler(this);
|
||||||
|
/**
|
||||||
|
* Emitted whenever there is a warning
|
||||||
|
* @event VoiceReceiver#debug
|
||||||
|
* @param {Error|string} error The error or message to debug
|
||||||
|
*/
|
||||||
|
this.packets.on('error', err => this.emit('debug', err));
|
||||||
this.connection.sockets.udp.socket.on('message', buffer => this.packets.push(buffer));
|
this.connection.sockets.udp.socket.on('message', buffer => this.packets.push(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,10 +27,6 @@ class VoiceReceiver extends EventEmitter {
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
stoppedSpeaking() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = VoiceReceiver;
|
module.exports = VoiceReceiver;
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ class VoiceReceiver extends EventEmitter {
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a readable stream for a user that provides PCM data while the user is speaking. When the user
|
* Creates a readable stream for a user that provides PCM data while the user is speaking. When the user
|
||||||
* stops speaking, the stream is destroyed. The stream is 32-bit signed stereo PCM at 48KHz.
|
* stops speaking, the stream is destroyed. The stream is 32-bit signed stereo PCM at 48KHz.
|
||||||
* @param {UserResolvable} user The user to create the stream for
|
* @param {UserResolvable} user The user to create the stream for
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue