Prevent duplicate incoming stream events on connect

This commit is contained in:
RogueException
2017-04-01 13:44:35 -03:00
parent fd043b3d53
commit 6798ba0d4b
2 changed files with 12 additions and 4 deletions

View File

@@ -433,7 +433,13 @@ namespace Discord.WebSocket
if (_audioClient != null && before.VoiceChannel?.Id != after.VoiceChannel?.Id)
{
if (model.UserId == CurrentUser.Id)
await RepopulateAudioStreamsAsync().ConfigureAwait(false);
{
if (after.VoiceChannel != null && _audioClient.ChannelId != after.VoiceChannel?.Id)
{
_audioClient.ChannelId = after.VoiceChannel.Id;
await RepopulateAudioStreamsAsync().ConfigureAwait(false);
}
}
else
{
await _audioClient.RemoveInputStreamAsync(model.UserId).ConfigureAwait(false); //User changed channels, end their stream
@@ -480,7 +486,7 @@ namespace Discord.WebSocket
if (_audioClient == null)
{
var audioClient = new AudioClient(this, Discord.GetAudioId());
var audioClient = new AudioClient(this, Discord.GetAudioId(), channelId);
audioClient.Disconnected += async ex =>
{
if (!promise.Task.IsCompleted)