Driver: Migrate to tokio_tungstenite (#138)
This places songbird, serenity, and twilight onto the same WS library, hopefully reducing the compile overhead for everyone. Tested using `cargo make ready` and by running `examples/voice`. Closes #129.
This commit is contained in:
@@ -12,7 +12,7 @@ use crate::{
|
||||
Event as GatewayEvent,
|
||||
ProtocolData,
|
||||
},
|
||||
ws::{self, ReceiverExt, SenderExt, WsStream},
|
||||
ws::WsStream,
|
||||
ConnectionInfo,
|
||||
};
|
||||
use discortp::discord::{IpDiscoveryPacket, IpDiscoveryType, MutableIpDiscoveryPacket};
|
||||
@@ -24,12 +24,6 @@ use tracing::{debug, info, instrument};
|
||||
use url::Url;
|
||||
use xsalsa20poly1305::{aead::NewAead, XSalsa20Poly1305 as Cipher};
|
||||
|
||||
#[cfg(all(feature = "rustls-marker", not(feature = "native-marker")))]
|
||||
use ws::create_rustls_client;
|
||||
|
||||
#[cfg(feature = "native-marker")]
|
||||
use ws::create_native_tls_client;
|
||||
|
||||
pub(crate) struct Connection {
|
||||
pub(crate) info: ConnectionInfo,
|
||||
pub(crate) ssrc: u32,
|
||||
@@ -58,11 +52,7 @@ impl Connection {
|
||||
) -> Result<Connection> {
|
||||
let url = generate_url(&mut info.endpoint)?;
|
||||
|
||||
#[cfg(all(feature = "rustls-marker", not(feature = "native-marker")))]
|
||||
let mut client = create_rustls_client(url).await?;
|
||||
|
||||
#[cfg(feature = "native-marker")]
|
||||
let mut client = create_native_tls_client(url).await?;
|
||||
let mut client = WsStream::connect(url).await?;
|
||||
|
||||
let mut hello = None;
|
||||
let mut ready = None;
|
||||
@@ -241,12 +231,7 @@ impl Connection {
|
||||
|
||||
// Thread may have died, we want to send to prompt a clean exit
|
||||
// (if at all possible) and then proceed as normal.
|
||||
|
||||
#[cfg(all(feature = "rustls-marker", not(feature = "native-marker")))]
|
||||
let mut client = create_rustls_client(url).await?;
|
||||
|
||||
#[cfg(feature = "native-marker")]
|
||||
let mut client = create_native_tls_client(url).await?;
|
||||
let mut client = WsStream::connect(url).await?;
|
||||
|
||||
client
|
||||
.send_json(&GatewayEvent::from(Resume {
|
||||
|
||||
@@ -8,10 +8,9 @@ use crate::{
|
||||
FromPrimitive,
|
||||
SpeakingState,
|
||||
},
|
||||
ws::{Error as WsError, ReceiverExt, SenderExt, WsStream},
|
||||
ws::{Error as WsError, WsStream},
|
||||
ConnectionInfo,
|
||||
};
|
||||
use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
||||
use flume::Receiver;
|
||||
use rand::random;
|
||||
use std::time::Duration;
|
||||
@@ -19,6 +18,7 @@ use tokio::{
|
||||
select,
|
||||
time::{sleep_until, Instant},
|
||||
};
|
||||
use tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
||||
use tracing::{debug, info, instrument, trace, warn};
|
||||
|
||||
struct AuxNetwork {
|
||||
|
||||
Reference in New Issue
Block a user