[Fix] Receiving voice packets (use system-assigned port) (#2857)
* Voice receive fix (use system-selected port) * Update SocketGuild.cs --------- Co-authored-by: Misha133 <mihagribkov133@gmail.com>
This commit is contained in:
@@ -321,11 +321,9 @@ namespace Discord.Audio
|
||||
return;
|
||||
}
|
||||
string ip;
|
||||
int port;
|
||||
try
|
||||
{
|
||||
ip = Encoding.UTF8.GetString(packet, 8, 74 - 10).TrimEnd('\0');
|
||||
port = (packet[73] << 8) | packet[72];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -334,7 +332,7 @@ namespace Discord.Audio
|
||||
}
|
||||
|
||||
await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false);
|
||||
await ApiClient.SendSelectProtocol(ip, port).ConfigureAwait(false);
|
||||
await ApiClient.SendSelectProtocol(ip).ConfigureAwait(false);
|
||||
}
|
||||
else if (_connection.State == ConnectionState.Connected)
|
||||
{
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Discord.Audio
|
||||
});
|
||||
}
|
||||
|
||||
public Task SendSelectProtocol(string externalIp, int externalPort)
|
||||
public Task SendSelectProtocol(string externalIp)
|
||||
{
|
||||
return SendAsync(VoiceOpCode.SelectProtocol, new SelectProtocolParams
|
||||
{
|
||||
@@ -151,7 +151,7 @@ namespace Discord.Audio
|
||||
Data = new UdpProtocolInfo
|
||||
{
|
||||
Address = externalIp,
|
||||
Port = externalPort,
|
||||
Port = UdpPort,
|
||||
Mode = Mode
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1744,11 +1744,9 @@ namespace Discord.WebSocket
|
||||
|
||||
if (external)
|
||||
{
|
||||
#pragma warning disable IDISP001
|
||||
var _ = promise.TrySetResultAsync(null);
|
||||
_ = promise.TrySetResultAsync(null);
|
||||
await Discord.ApiClient.SendVoiceStateUpdateAsync(_voiceStateUpdateParams).ConfigureAwait(false);
|
||||
return null;
|
||||
#pragma warning restore IDISP001
|
||||
}
|
||||
|
||||
if (_audioClient == null)
|
||||
@@ -1766,19 +1764,15 @@ namespace Discord.WebSocket
|
||||
await promise.TrySetExceptionAsync(ex);
|
||||
else
|
||||
await promise.TrySetCanceledAsync();
|
||||
return;
|
||||
}
|
||||
};
|
||||
audioClient.Connected += () =>
|
||||
{
|
||||
#pragma warning disable IDISP001
|
||||
var _ = promise.TrySetResultAsync(_audioClient);
|
||||
#pragma warning restore IDISP001
|
||||
_ = promise.TrySetResultAsync(_audioClient);
|
||||
return Task.Delay(0);
|
||||
};
|
||||
#pragma warning disable IDISP003
|
||||
|
||||
_audioClient = audioClient;
|
||||
#pragma warning restore IDISP003
|
||||
}
|
||||
|
||||
await Discord.ApiClient.SendVoiceStateUpdateAsync(_voiceStateUpdateParams).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user