fix(Voice): correctly set speaking data in the voice ssrcMap

Co-authored-by: Sillyfrog <sillyfrog@users.noreply.github.com>
This commit is contained in:
sillyfrog
2020-05-01 02:21:29 +10:00
committed by GitHub
parent 026691702d
commit d3c9384c9c
2 changed files with 6 additions and 1 deletions

View File

@@ -189,7 +189,7 @@ class VoiceWebSocket extends EventEmitter {
this.emit('sessionDescription', packet.d);
break;
case VoiceOPCodes.CLIENT_CONNECT:
this.connection.ssrcMap.set(+packet.d.audio_ssrc, packet.d.user_id);
this.connection.ssrcMap.set(+packet.d.audio_ssrc, { userID: packet.d.user_id, speaking: 0 });
break;
case VoiceOPCodes.CLIENT_DISCONNECT:
const streamInfo = this.connection.receiver && this.connection.receiver.packets.streams.get(packet.d.user_id);

View File

@@ -86,6 +86,11 @@ class PacketHandler extends EventEmitter {
let speakingTimeout = this.speakingTimeouts.get(ssrc);
if (typeof speakingTimeout === 'undefined') {
// Ensure at least the speaking bit is set.
// As the object is by reference, it's only needed once per client re-connect.
if (userStat.speaking === 0) {
userStat.speaking = 1;
}
this.connection.onSpeaking({ user_id: userStat.userID, ssrc: ssrc, speaking: userStat.speaking });
speakingTimeout = this.receiver.connection.client.setTimeout(() => {
try {