Fixed incoming audio, removed nameresolution dep.
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Discord.Net.Udp
|
||||
event Func<byte[], int, int, Task> ReceivedDatagram;
|
||||
|
||||
void SetCancelToken(CancellationToken cancelToken);
|
||||
void SetDestination(string host, int port);
|
||||
void SetDestination(string ip, int port);
|
||||
|
||||
Task StartAsync();
|
||||
Task StopAsync();
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Discord.API.Voice
|
||||
{
|
||||
[JsonProperty("ssrc")]
|
||||
public uint SSRC { get; set; }
|
||||
[JsonProperty("ip")]
|
||||
public string Ip { get; set; }
|
||||
[JsonProperty("port")]
|
||||
public ushort Port { get; set; }
|
||||
[JsonProperty("modes")]
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Discord.Audio
|
||||
|
||||
_heartbeatTask = RunHeartbeatAsync(data.HeartbeatInterval, _connection.CancelToken);
|
||||
|
||||
ApiClient.SetUdpEndpoint(_url, data.Port);
|
||||
ApiClient.SetUdpEndpoint(data.Ip, data.Port);
|
||||
await ApiClient.SendDiscoveryAsync(_ssrc).ConfigureAwait(false);
|
||||
}
|
||||
break;
|
||||
@@ -302,7 +302,7 @@ namespace Discord.Audio
|
||||
}
|
||||
private async Task ProcessPacketAsync(byte[] packet)
|
||||
{
|
||||
if (!_connection.IsCompleted)
|
||||
if (_connection.State == ConnectionState.Connecting)
|
||||
{
|
||||
if (packet.Length != 70)
|
||||
{
|
||||
@@ -314,7 +314,7 @@ namespace Discord.Audio
|
||||
try
|
||||
{
|
||||
ip = Encoding.UTF8.GetString(packet, 4, 70 - 6).TrimEnd('\0');
|
||||
port = packet[69] | (packet[68] << 8);
|
||||
port = (packet[69] << 8) | packet[68];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ namespace Discord.Audio
|
||||
await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false);
|
||||
await ApiClient.SendSelectProtocol(ip, port).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
else if (_connection.State == ConnectionState.Connected)
|
||||
{
|
||||
uint ssrc;
|
||||
ulong userId;
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace Discord
|
||||
public ConnectionState State { get; private set; }
|
||||
public CancellationToken CancelToken { get; private set; }
|
||||
|
||||
public bool IsCompleted => _readyPromise.Task.IsCompleted;
|
||||
|
||||
internal ConnectionManager(SemaphoreSlim stateLock, Logger logger, int connectionTimeout,
|
||||
Func<Task> onConnecting, Func<Exception, Task> onDisconnecting, Action<Func<Exception, Task>> clientDisconnectHandler)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
|
||||
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
|
||||
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
|
||||
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -228,9 +228,9 @@ namespace Discord.Audio
|
||||
await _sentDiscoveryEvent.InvokeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public void SetUdpEndpoint(string host, int port)
|
||||
public void SetUdpEndpoint(string ip, int port)
|
||||
{
|
||||
_udp.SetDestination(host, port);
|
||||
_udp.SetDestination(ip, port);
|
||||
}
|
||||
|
||||
//Helpers
|
||||
|
||||
@@ -89,10 +89,9 @@ namespace Discord.Net.Udp
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDestination(string host, int port)
|
||||
public void SetDestination(string ip, int port)
|
||||
{
|
||||
var entry = Dns.GetHostEntryAsync(host).GetAwaiter().GetResult();
|
||||
_destination = new IPEndPoint(entry.AddressList[0], port);
|
||||
_destination = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||
}
|
||||
public void SetCancelToken(CancellationToken cancelToken)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user