Browse Source

Fixed incoming audio, removed nameresolution dep.

tags/1.0-rc
RogueException 8 years ago
parent
commit
3e988c7549
7 changed files with 11 additions and 13 deletions
  1. +1
    -1
      src/Discord.Net.Core/Net/Udp/IUdpSocket.cs
  2. +2
    -0
      src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs
  3. +4
    -4
      src/Discord.Net.WebSocket/Audio/AudioClient.cs
  4. +0
    -2
      src/Discord.Net.WebSocket/ConnectionManager.cs
  5. +0
    -1
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
  6. +2
    -2
      src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs
  7. +2
    -3
      src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs

+ 1
- 1
src/Discord.Net.Core/Net/Udp/IUdpSocket.cs View File

@@ -9,7 +9,7 @@ namespace Discord.Net.Udp
event Func<byte[], int, int, Task> ReceivedDatagram; event Func<byte[], int, int, Task> ReceivedDatagram;


void SetCancelToken(CancellationToken cancelToken); void SetCancelToken(CancellationToken cancelToken);
void SetDestination(string host, int port);
void SetDestination(string ip, int port);


Task StartAsync(); Task StartAsync();
Task StopAsync(); Task StopAsync();


+ 2
- 0
src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs View File

@@ -7,6 +7,8 @@ namespace Discord.API.Voice
{ {
[JsonProperty("ssrc")] [JsonProperty("ssrc")]
public uint SSRC { get; set; } public uint SSRC { get; set; }
[JsonProperty("ip")]
public string Ip { get; set; }
[JsonProperty("port")] [JsonProperty("port")]
public ushort Port { get; set; } public ushort Port { get; set; }
[JsonProperty("modes")] [JsonProperty("modes")]


+ 4
- 4
src/Discord.Net.WebSocket/Audio/AudioClient.cs View File

@@ -248,7 +248,7 @@ namespace Discord.Audio


_heartbeatTask = RunHeartbeatAsync(data.HeartbeatInterval, _connection.CancelToken); _heartbeatTask = RunHeartbeatAsync(data.HeartbeatInterval, _connection.CancelToken);
ApiClient.SetUdpEndpoint(_url, data.Port);
ApiClient.SetUdpEndpoint(data.Ip, data.Port);
await ApiClient.SendDiscoveryAsync(_ssrc).ConfigureAwait(false); await ApiClient.SendDiscoveryAsync(_ssrc).ConfigureAwait(false);
} }
break; break;
@@ -302,7 +302,7 @@ namespace Discord.Audio
} }
private async Task ProcessPacketAsync(byte[] packet) private async Task ProcessPacketAsync(byte[] packet)
{ {
if (!_connection.IsCompleted)
if (_connection.State == ConnectionState.Connecting)
{ {
if (packet.Length != 70) if (packet.Length != 70)
{ {
@@ -314,7 +314,7 @@ namespace Discord.Audio
try try
{ {
ip = Encoding.UTF8.GetString(packet, 4, 70 - 6).TrimEnd('\0'); 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) catch (Exception ex)
{ {
@@ -325,7 +325,7 @@ namespace Discord.Audio
await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false); await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false);
await ApiClient.SendSelectProtocol(ip, port).ConfigureAwait(false); await ApiClient.SendSelectProtocol(ip, port).ConfigureAwait(false);
} }
else
else if (_connection.State == ConnectionState.Connected)
{ {
uint ssrc; uint ssrc;
ulong userId; ulong userId;


+ 0
- 2
src/Discord.Net.WebSocket/ConnectionManager.cs View File

@@ -26,8 +26,6 @@ namespace Discord
public ConnectionState State { get; private set; } public ConnectionState State { get; private set; }
public CancellationToken CancelToken { get; private set; } public CancellationToken CancelToken { get; private set; }


public bool IsCompleted => _readyPromise.Task.IsCompleted;

internal ConnectionManager(SemaphoreSlim stateLock, Logger logger, int connectionTimeout, internal ConnectionManager(SemaphoreSlim stateLock, Logger logger, int connectionTimeout,
Func<Task> onConnecting, Func<Exception, Task> onDisconnecting, Action<Func<Exception, Task>> clientDisconnectHandler) Func<Task> onConnecting, Func<Exception, Task> onDisconnecting, Action<Func<Exception, Task>> clientDisconnectHandler)
{ {


+ 0
- 1
src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj View File

@@ -16,7 +16,6 @@
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" /> <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' "> <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.Sockets" Version="4.3.0" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.0" /> <PackageReference Include="System.Net.WebSockets.Client" Version="4.3.0" />
</ItemGroup> </ItemGroup>

+ 2
- 2
src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs View File

@@ -228,9 +228,9 @@ namespace Discord.Audio
await _sentDiscoveryEvent.InvokeAsync().ConfigureAwait(false); 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 //Helpers


+ 2
- 3
src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs View File

@@ -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) public void SetCancelToken(CancellationToken cancelToken)
{ {


Loading…
Cancel
Save