Songbird: Tokio 1.0 (#36)

Migrates to the new version of tokio, requiring channel and sleep changes in a few locations. Additionally points to the in-tree v0.3 version of twilight.
This commit is contained in:
Kyle Simpson
2021-01-06 13:01:14 +00:00
committed by GitHub
parent d42e09f72b
commit f05b7414a0
14 changed files with 57 additions and 49 deletions

View File

@@ -18,7 +18,7 @@ use crate::{
use discortp::discord::{IpDiscoveryPacket, IpDiscoveryType, MutableIpDiscoveryPacket};
use error::{Error, Result};
use flume::Sender;
use std::{net::IpAddr, str::FromStr};
use std::{net::IpAddr, str::FromStr, sync::Arc};
use tokio::net::UdpSocket;
use tracing::{debug, info, instrument};
use url::Url;
@@ -97,7 +97,7 @@ impl Connection {
return Err(Error::CryptoModeUnavailable);
}
let mut udp = UdpSocket::bind("0.0.0.0:0").await?;
let udp = UdpSocket::bind("0.0.0.0:0").await?;
udp.connect((ready.ip, ready.port)).await?;
// Follow Discord's IP Discovery procedures, in case NAT tunnelling is needed.
@@ -161,7 +161,9 @@ impl Connection {
let (ws_msg_tx, ws_msg_rx) = flume::unbounded();
let (udp_sender_msg_tx, udp_sender_msg_rx) = flume::unbounded();
let (udp_receiver_msg_tx, udp_receiver_msg_rx) = flume::unbounded();
let (udp_rx, udp_tx) = udp.split();
let udp_rx = Arc::new(udp);
let udp_tx = Arc::clone(&udp_rx);
let ssrc = ready.ssrc;